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 tidy_ks (output from tidy_k*) or object of class sf_ks (output from st_k*)

mapping

default list of aesthetic mappings to use for plot.

which_geometry

type of geometry to display: one of c("sf", "grid"). Default is "sf".

...

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_geometry

type of geometry to display: one of c("sf", "grid"). Default is "sf".

cont

vector of percentages for contour heights

abs_cont

vector of values for contour heights

which_deriv_ind

index for partial derivative for density derivative estimate. Default is 1.

main

main plot label. Default is "".

legend

flag to add legend. Default is TRUE. The output from mapsf::mf_legend in base R is not as robust as the legend output in ggplot2.

...

other graphics parameters in the plot method for sf objects or for mapsf::mf_legend.

Value

ggplot plot object is created. Base R plot is sent to graphics window.

See Also

tidy_kde,st_kde


[Package eks version 1.0.4 Index]