Create a ggplot2 histogram of a RasterLayer.

plot_hist(
  x,
  mask.obj = NULL,
  add.mean = FALSE,
  add.median = FALSE,
  save.dir = "",
  binwidth = 0.05,
  title = NULL
)

Arguments

x

RasterLayer object containing the spatial data.

mask.obj

RasterLayer object optionally used for masking only specific parts of x.

add.mean

Boolean whether a vertical blue line is added to the plot indicating the mean value of x.

add.median

Boolean whether a vertical red line is added to the plot indicating the median value of x.

save.dir

Character path (folder) for saving the plot as an image.

binwidth

Double value of bindwidth for geom_bar.

title

Character string title of the plot.

Value

a ggplot object containing the plot.

See also

geom_bar.