Plots for tidy and geospatial kernel estimates
tidyst_plot.RdPlots for tidy and geospatial kernel estimates.
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", cont=c(25,50,75), abs_cont=breaks, breaks,
which_deriv_ind=1, pal, col, legend=TRUE, legend.title, digits=4, ...)where
which_geometrytype of geometry to display: one of
c("sf", "grid"). Default is"sf".contvector of percentages for contour heights
abs_cont,breaksvector of values for contour heights
which_deriv_indindex for partial derivative for density derivative estimate. Default is 1.
palcolour palette function
colvector of colours
legendflag to add legend. Default is TRUE. The output from
mapsf::mf_legendin base R is not as robust as the legend output inggplot2.legend.titlelegend title
digitsnumber of significant digits in legend key. Default is 4.
- ...
other graphics parameters in the
plotmethod forsfobjects or formapsf::mf_legend.