scale_color_geo | R Documentation |
Color scales using the colors in the Geological Time Scale graphics.
scale_color_geo(dat, ...)
scale_fill_geo(dat, ...)
scale_discrete_geo(dat, aesthetics, ...)
dat |
Either A) a string indicating a built-in dataframe with interval
data from the ICS ("periods", "epochs", "stages", "eons", or "eras"),
B) a string indicating a timescale from macrostrat (see list here:
https://macrostrat.org/api/defs/timescales?all),
or C) a custom data.frame of time interval boundaries
(see |
... |
Arguments passed on to
|
aesthetics |
Character string or vector of character strings listing the
name(s) of the aesthetic(s) that this scale works with. This can be useful, for
example, to apply colour settings to the |
library(ggplot2)
df <- data.frame(
x = runif(1000, 0, 10), y = runif(1000, 0, 10),
color = sample(periods$name, 1000, TRUE), shape = 21
)
ggplot(df) +
geom_point(aes(x = x, y = y, fill = color), shape = 21) +
scale_fill_geo("periods", name = "Period") +
theme_classic()
# cut continuous variable into discrete
df <- data.frame(x = runif(1000, 0, 1000), y = runif(1000, 0, 8))
df$color <- cut(df$x, c(periods$min_age, periods$max_age[22]), periods$name)
ggplot(df) +
geom_point(aes(x = x, y = y, color = color)) +
scale_x_reverse() +
scale_color_geo("periods", name = "Period") +
coord_geo(xlim = c(1000, 0), ylim = c(0, 8)) +
theme_classic()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.