geom_latFreq | R Documentation |
geom_latFreq
geom_latFreq(
mapping = NULL,
data = NULL,
stat = "identity",
position = "identity",
...,
options = list(),
bbox = c(185, 240, -60, 90),
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
stat |
The statistical transformation to use on the data for this layer.
When using a
|
position |
A position adjustment to use on the data for this layer. This
can be used in various ways, including to prevent overplotting and
improving the display. The
|
... |
Other arguments passed on to
|
options |
parameters of |
bbox |
bounding box of the plot, in the form of |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
library(ggplot2)
# the lattice version: https://github.com/CUG-hydro/Liu2021-JGRA-ET_trends_attribution
# f <- "data-raw/AridityIndex_MSWEP-prcp_div_GLEAM-Ep_1980-2020.tif"
# r <- terra::rast(f)
# d <- as.data.table(r, xy = TRUE) |> set_names(c("x", "y", "z"))
d = AridityIndex
# make_latFreq(d$y, d$z, debug = TRUE, zlim = c(-2, 2), is_spatial = TRUE)
# brks <- c(-Inf, 0.05, 0.2, 0.5, 0.65, Inf)
brks <- c(-Inf, 0.05, 0.2, 0.5, 0.65, 1:5, 20, Inf)
nbrk <- length(brks) - 1
cols <- rcolors::get_color("amwg256", nbrk) |> rev()
p = ggplot(d, aes(x, y, z = z)) +
geom_raster_filled(breaks = brks) +
geom_latFreq(options = list(is_spatial = TRUE, zlim = c(-1, 1)*10),
bbox = c(190, 240, -60, 90)) +
coord_cartesian(xlim = c(-180, 240), ylim = c(-60, 90), expand = FALSE, clip = "on") +
scale_x_continuous(limits = c(-180, 240), breaks = seq(-180, 180, 60)) +
scale_fill_manual(values =cols) +
labs(x = NULL, y = NULL)
p
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.