| tidyst_plot {eks} | R Documentation |
Plots for tidy and geospatial kernel estimates
Description
Plots for tidy and geospatial kernel estimates.
Usage
## S3 method for class 'tidy_ks'
ggplot(data=NULL, mapping=aes(), ...)
## S3 method for class 'sf_ks'
ggplot(data=NULL, mapping=aes(), ..., which_geometry="sf")
## S3 method for class 'sf_ks'
plot(x, ...)
Arguments
data, x |
object of class |
mapping |
default list of aesthetic mappings to use for plot. |
which_geometry |
type of geometry to display: one of |
... |
other graphics parameters. See below. |
Details
For tidy_ks objects, the ggplot method adds some default aesthetics based on derived variables in the computed kernel estimate. These are aes(y=estimate, weight=ks) (1-d) and are aes(z=estimate, weight=ks) (2-d). These derived variables computed in the tibble output from tidy_k* are: estimate is the kernel estimate value and ks is the untidy version of the kernel estimate, which is required to compute contour levels. The ggplot method also adds some default labels for the axes and grouping variable, and some default formatting for the legends. These defaults replicate the appearance of the corresponding plots from the ks package.
For sf_ks objects, the ggplot method is similar to the above method, except no default aesthetics are added. The function header for the plot method is
plot(x, which_geometry="sf", percent_label=TRUE, cont=c(25,50,75),
abs_cont, which_deriv_ind=1, main="", legend=TRUE, ...)
where
which_geometrytype of geometry to display: one of
c("sf", "grid"). Default is"sf".contvector of percentages for contour heights
abs_contvector of values for contour heights
which_deriv_indindex for partial derivative for density derivative estimate. Default is 1.
mainmain plot label. Default is "".
legendflag to add legend. Default is TRUE. The output from
mapsf::mf_legendin base R is not as robust as the legend output inggplot2.- ...
other graphics parameters in the
plotmethod forsfobjects or formapsf::mf_legend.
Value
ggplot plot object is created. Base R plot is sent to graphics window.