Title: | Plotting Tools for Anyone Working in Deep Time |
Version: | 2.2.0 |
Maintainer: | William Gearty <willgearty@gmail.com> |
Description: | Extends the functionality of other plotting packages (notably 'ggplot2') to help facilitate the plotting of data over long time intervals, including, but not limited to, geological, evolutionary, and ecological data. The primary goal of 'deeptime' is to enable users to add highly customizable timescales to their visualizations. Other functions are also included to assist with other areas of deep time visualization. |
URL: | https://williamgearty.com/deeptime/, https://github.com/willgearty/deeptime |
BugReports: | https://github.com/willgearty/deeptime/issues |
Depends: | R (≥ 3.5) |
License: | GPL (≥ 3) |
Encoding: | UTF-8 |
RoxygenNote: | 7.3.2 |
LazyData: | true |
Imports: | deeptimedata, ggplot2 (≥ 3.5.0), utils, ggforce, grid, gridExtra, gtable, methods, stats, lattice, rlang (≥ 1.1.0), scales, ggfittext, curl, cli, lifecycle, grImport2, ggh4x |
Suggests: | geomtextpath, phytools, dplyr, divDyn, gsloid, ape, palaeoverse, paleotree, dispRity, ggtree (≥ 3.6.1), testthat (≥ 3.0.0), vdiffr (≥ 1.0.8), knitr, rmarkdown, withr, ggpattern, ggrepel, rmacrostrat, svglite |
VignetteBuilder: | knitr |
Config/testthat/edition: | 3 |
Config/Needs/revdeps: | revdepcheck |
NeedsCompilation: | no |
Packaged: | 2025-06-18 21:59:18 UTC; willg |
Author: | William Gearty |
Repository: | CRAN |
Date/Publication: | 2025-06-19 19:10:07 UTC |
deeptime: Plotting Tools for Anyone Working in Deep Time
Description
Extends the functionality of other plotting packages (notably 'ggplot2') to help facilitate the plotting of data over long time intervals, including, but not limited to, geological, evolutionary, and ecological data. The primary goal of 'deeptime' is to enable users to add highly customizable timescales to their visualizations. Other functions are also included to assist with other areas of deep time visualization.
Author(s)
Maintainer: William Gearty willgearty@gmail.com (ORCID)
See Also
Useful links:
Report bugs at https://github.com/willgearty/deeptime/issues
Transformed coordinate system with geological timescale
Description
coord_geo
behaves similarly to ggplot2::coord_trans()
in that it occurs
after statistical transformation and will affect the visual appearance of
geoms. The main difference is that it also adds a geological timescale to the
specified side(s) of the plot.
Usage
coord_geo(
pos = "bottom",
dat = "periods",
xlim = NULL,
ylim = NULL,
xtrans = identity_trans(),
ytrans = identity_trans(),
clip = "on",
expand = FALSE,
fill = NULL,
alpha = 1,
height = unit(2, "line"),
bord = c("left", "right", "top", "bottom"),
lwd = 0.25,
color = "black",
lab = TRUE,
lab_color = NULL,
rot = 0,
family = "sans",
fontface = "plain",
size = 5,
skip = c("Quaternary", "Holocene", "Late Pleistocene"),
abbrv = TRUE,
neg = FALSE,
center_end_labels = FALSE,
dat_is_discrete = FALSE,
fittext_args = list()
)
Arguments
pos |
Which side to add the scale to (left, right, top, or bottom). First letter may also be used. |
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 Details). |
xlim , ylim |
Limits for the x and y axes. |
xtrans , ytrans |
Transformers for the x and y axes. For more information
see |
clip |
Should drawing be clipped to the extent of the plot panel? A
setting of |
expand |
If |
fill |
The fill color of the boxes. The default is to use the |
alpha |
The transparency of the fill colors. |
height |
The height (or width if |
bord |
A vector specifying on which sides of the scale to add borders
(same options as |
lwd |
Line width. |
color |
The outline color of the interval boxes. |
lab |
Whether to include labels. |
lab_color |
The color of the labels. The default is to use the
|
rot |
The amount of counter-clockwise rotation to add to the labels (in degrees). |
family |
The font family to use for the labels. There are only three fonts that are guaranteed to work everywhere: “sans” (the default), “serif”, or “mono”. |
fontface |
The font face to use for the labels. The standard options are "plain" (default), "bold", "italic", and "bold.italic". |
size |
Label size. Either a number as you would specify in
|
skip |
A vector of interval names indicating which intervals should not
be labeled. If |
abbrv |
If including labels, should the labels be abbreviated? If
|
neg |
Set this to |
center_end_labels |
Should labels be centered within the visible range of intervals at the ends of the axis? |
dat_is_discrete |
Are the ages in |
fittext_args |
A list of named arguments to provide to
|
Details
Transforming the side with the scale is not currently implemented.
If a custom data.frame is provided (with dat
), it should consist of at
least 3 columns of data. See data(periods)
for an example.
The
name
column lists the names of each time interval. These will be used as labels if no abbreviations are provided.The
max_age
column lists the oldest boundary of each time interval.The
min_age
column lists the youngest boundary of each time interval.The
abbr
column is optional and lists abbreviations that may be used as labels.The
color
column is also optional and lists a color for the background for each time interval.The
lab_color
column is also optional and lists a color for the label for each time interval.
If the axis of the time scale is discrete, max_age
and min_age
will
automatically be converted to the discrete scale. In this case, the
categories of the discrete axis should match the values in the name
column.
If the ages within dat
are already discretized, you can set
dat_is_discrete
to TRUE
to prevent this automatic conversion. This can be
useful for adding a time scale where categories and time intervals are not
1:1.
pos
may also be a list
of sides (including duplicates) if multiple time
scales should be added to the plot. In this case, dat
, fill
, alpha
,
height
, bord
, lwd
, color
, lab
, lab_color
, rot
, family
,
fontface
, size
, skip
, abbrv
, neg
, center_end_labels
, and
dat_is_discrete
can also be list
s. If these list
s are not as long as
pos
, the elements will be recycled.
If individual values (or vectors) are used for these parameters, they will be
applied to all time scales (and recycled as necessary).
Examples
library(ggplot2)
# single scale on bottom
ggplot() +
geom_point(aes(y = runif(1000, 0, 8), x = runif(1000, 0, 1000))) +
scale_x_reverse() +
coord_geo(xlim = c(1000, 0), ylim = c(0, 8)) +
theme_classic()
# stack multiple scales
ggplot() +
geom_point(aes(y = runif(1000, 0, 8), x = runif(1000, 0, 100))) +
scale_x_reverse() +
coord_geo(
xlim = c(100, 0), ylim = c(0, 8), pos = as.list(rep("bottom", 3)),
dat = list("stages", "epochs", "periods"),
height = list(unit(4, "lines"), unit(4, "lines"), unit(2, "line")),
rot = list(90, 90, 0), size = list(2.5, 2.5, 5), abbrv = FALSE
) +
theme_classic()
Polar coordinate system with geological timescale
Description
coord_geo_polar
behaves similarly to ggplot2::coord_polar()
in that it
occurs after statistical transformation and will affect the visual appearance
of geoms. The main difference is that it also adds a geological timescale to
the background of the plot.
Usage
coord_geo_polar(
dat = "periods",
theta = "y",
start = -pi/2,
direction = -1,
clip = "on",
fill = NULL,
alpha = 1,
lwd = 0.25,
color = "grey80",
lty = "solid",
lab = FALSE,
abbrv = TRUE,
skip = c("Quaternary", "Holocene", "Late Pleistocene"),
neg = TRUE,
prop = 1,
textpath_args = list()
)
Arguments
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 Details). |
theta |
variable to map angle to ( |
start |
Offset of starting point from 12 o'clock in radians. Offset
is applied clockwise or anticlockwise depending on value of |
direction |
1, clockwise; -1, anticlockwise |
clip |
Should drawing be clipped to the extent of the plot panel? A
setting of |
fill |
The fill color of the background. The default is to use the
|
alpha |
The transparency of the fill colors. |
lwd |
Line width for lines between intervals. Set to |
color |
The color of the lines between intervals. |
lty |
Line type for lines between intervals. |
lab |
Whether to include labels. Requires the |
abbrv |
If including labels, whether to use abbreviations instead of full interval names. |
skip |
A vector of interval names indicating which intervals should not
be labeled. If |
neg |
Set this to true if your theta-axis is using negative values. This
is usually true if you are using |
prop |
This is the rotational proportion of the background that the scale takes up. |
textpath_args |
A list of named arguments to provide to
|
Details
If a custom data.frame is provided (with dat
), it should consist of at
least 2 columns of data. See data(periods)
for an example.
The
max_age
column lists the oldest boundary of each time interval.The
min_age
column lists the youngest boundary of each time interval.The
abbr
column is optional and lists abbreviations that may be used as labels.The
color
column is optional and lists a color for the background for each time interval.
dat
may also be a list of values and/or dataframes if multiple time scales
should be added to the background. Scales will be added sequentially starting
at start
and going in the specified direction
. By default the scales will
all be equal in circular/rotational proportion, but this can be overridden
with prop
. If dat
is a list, fill
, alpha
, lwd
, color
, lty
,
lab
, abbrv
, skip
, neg
, prop
, and textpath_args
can also be lists
(N.B. textpath_args
would be a list of lists). If these lists are not as
long as dat
, the elements will be recycled. If individual values (or
vectors) are used for these parameters, they will be applied to all time
scales (and recycled as necessary).
If the sum of the prop
values is greater than 1, the proportions will be
scaled such that they sum to 1. However, the prop
values may sum to less
than 1 if the user would like blank space in the background.
coord_geo_polar
manually generates the r
axis, meaning it does not
support changing the guide features of ggplot v. 2.5.0 or later. However, the
deeptime.axis.line.r
, deeptime.axis.text.r
, deeptime.axis.ticks.r
, and
deeptime.axis.ticks.length.r
ggplot2 theme elements can
be modified just like their x and y counterparts to change the appearance of
the radius axis. The default settings work well for a horizontal axis
pointing towards the right, but these theme settings will need to be modified
for other orientations. The default value for deeptime.axis.line.r
is
element_line()
. The default value for deeptime.axis.text.r
is
element_text(size = 3.5, vjust = -2, hjust = -0.5)
. The default value
for deeptime.axis.ticks.r
is element_line()
. The default value for
deeptime.axis.ticks.length.r
is unit(1.5, "points")
. However, note that
the units for this element are meaningless and only the numeric value will be
used (but a unit
must still be used).
Care must be taken when adding labels to plots, as they are very likely to
overlap with the plot under the default settings. The textpath_args
argument can be used to adjust the settings for the plotting of the labels.
See geomtextpath::geom_textpath()
for details about the available
arguments. Also note that the curvature of the labels may vary based on the
distance from the origin. This is why abbrv
is set to TRUE
by default.
Life cycle
This function is soft-deprecated in favor of
coord_geo_radial()
as of deeptime version 1.1.0. There is currently
no plan to remove this function, but users are strongly encouraged to
migrate to the new function for enhanced polar functionality.
Examples
library(ggplot2)
library(ggtree)
set.seed(1)
tree <- rtree(100)
# single scale
revts(ggtree(tree)) +
coord_geo_polar(dat = "stages")
# multiple scales
revts(ggtree(tree)) +
coord_geo_polar(
dat = list("stages", "periods"), alpha = .5,
prop = list(0.75, .25), start = pi / 4, lty = "dashed"
) +
scale_y_continuous(expand = expansion(mult = c(0.02, 0.02))) +
theme(deeptime.axis.text.r = element_text(size = 3.5, hjust = .75,
vjust = .75))
library(ggplot2)
library(paleotree)
data(RaiaCopesRule)
ggtree(ceratopsianTreeRaia,
position = position_nudge(x = -ceratopsianTreeRaia$root.time)) +
coord_geo_polar(dat = "stages")
Enhanced polar coordinate system with geological timescale
Description
coord_geo_radial
behaves similarly to ggplot2::coord_radial()
in that it
occurs after statistical transformation and will affect the visual appearance
of geoms. The main difference is that it also adds a geological timescale to
the background of the plot. coord_geo_radial
is similar to
coord_geo_polar()
but has more options related to the polar coordinate
plotting that are inherited from ggplot2::coord_radial()
(e.g., end
,
r_axis_inside
, inner.radius
). Furthermore, unlike coord_geo_polar
,
coord_geo_radial
uses the ggplot2 internals to draw the r
and theta
axes, gridlines, etc. This means that users can tweak the
guide and theme settings for these
features (see examples).
Usage
coord_geo_radial(
dat = "periods",
theta = "y",
start = -0.5 * pi,
end = 1.25 * pi,
expand = TRUE,
direction = 1,
reverse = "none",
r_axis_inside = NULL,
inner.radius = 0.05,
fill = NULL,
alpha = 1,
lwd = 0.25,
color = "grey80",
lty = "solid",
lab = FALSE,
abbrv = TRUE,
skip = c("Quaternary", "Holocene", "Late Pleistocene"),
neg = TRUE,
prop = 1,
textpath_args = list(),
clip = "off",
rotate_angle = FALSE
)
Arguments
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 Details). |
theta |
variable to map angle to ( |
start |
Offset of starting point from 12 o'clock in radians. Offset
is applied clockwise or anticlockwise depending on value of |
end |
Position from 12 o'clock in radians where plot ends, to allow
for partial polar coordinates. The default, |
expand |
If |
direction |
1, clockwise; -1, anticlockwise |
reverse |
A string giving which directions to reverse. |
r_axis_inside , rotate_angle |
|
inner.radius |
A |
fill |
The fill color of the background. The default is to use the
|
alpha |
The transparency of the fill colors. |
lwd |
Line width for lines between intervals. Set to |
color |
The color of the lines between intervals. |
lty |
Line type for lines between intervals. |
lab |
Whether to include labels. Requires the |
abbrv |
If including labels, whether to use abbreviations instead of full interval names. |
skip |
A vector of interval names indicating which intervals should not
be labeled. If |
neg |
Set this to true if your theta-axis is using negative values. This
is usually true if you are using |
prop |
This is the rotational proportion of the background that the scale takes up. |
textpath_args |
A list of named arguments to provide to
|
clip |
Should drawing be clipped to the extent of the plot panel? A
setting of |
Details
If a custom data.frame is provided (with dat
), it should consist of at
least 2 columns of data. See data(periods)
for an example.
The
max_age
column lists the oldest boundary of each time interval.The
min_age
column lists the youngest boundary of each time interval.The
abbr
column is optional and lists abbreviations that may be used as labels.The
color
column is optional and lists a color for the background for each time interval.
dat
may also be a list of values and/or dataframes if multiple time scales
should be added to the background. Scales will be added sequentially starting
at start
and going in the specified direction
. By default the scales will
all be equal in circular/rotational proportion, but this can be overridden
with prop
. If dat
is a list, fill
, alpha
, lwd
, color
, lty
,
lab
, abbrv
, skip
, neg
, prop
, and textpath_args
can also be lists
(N.B. textpath_args
would be a list of lists). If these lists are not as
long as dat
, the elements will be recycled. If individual values (or
vectors) are used for these parameters, they will be applied to all time
scales (and recycled as necessary).
If the sum of the prop
values is greater than 1, the proportions will be
scaled such that they sum to 1. However, the prop
values may sum to less
than 1 if the user would like blank space in the background.
Care must be taken when adding labels to plots, as they are very likely to
overlap with the plot under the default settings. The textpath_args
argument can be used to adjust the settings for the plotting of the labels.
See geomtextpath::geom_textpath()
for details about the available
arguments. Also note that the curvature of the labels may vary based on the
distance from the origin. This is why abbrv
is set to TRUE
by default.
Examples
library(ggplot2)
library(ggtree)
set.seed(1)
tree <- rtree(100)
# single scale
revts(ggtree(tree)) +
coord_geo_radial(dat = "stages") +
scale_y_continuous(guide = "none", breaks = NULL) +
theme_gray()
# multiple scales
revts(ggtree(tree)) +
coord_geo_radial(
dat = list("stages", "periods"), alpha = .5,
prop = list(0.75, .25), start = pi / 4, end = 2 * pi, lty = "dashed"
) +
scale_y_continuous(expand = expansion(mult = c(0.02, 0.02)),
guide = "none", breaks = NULL) +
theme_gray()
library(ggplot2)
library(paleotree)
data(RaiaCopesRule)
ggtree(ceratopsianTreeRaia,
position = position_nudge(x = -ceratopsianTreeRaia$root.time)) +
coord_geo_radial(dat = "stages") +
scale_y_continuous(guide = "none", breaks = NULL) +
theme_classic()
Transformed and flipped Cartesian coordinate system
Description
coord_trans_flip
behaves similarly to ggplot2::coord_trans()
in that it
occurs after statistical transformation and will affect the visual appearance
of geoms. The main difference is that it also flips the x and y coordinates
like ggplot2::coord_flip()
.
Usage
coord_trans_flip(
x = "identity",
y = "identity",
xlim = NULL,
ylim = NULL,
clip = "on",
expand = TRUE
)
Arguments
x , y |
Transformers for x and y axes or their names. |
xlim , ylim |
Limits for the x and y axes. |
clip |
Should drawing be clipped to the extent of the plot panel? A
setting of |
expand |
If |
Examples
library(ggplot2)
ggplot(mtcars, aes(disp, wt)) +
geom_point() +
coord_trans_flip(x = "log10", y = "log10")
Transformed XY Cartesian coordinate system
Description
coord_trans_xy
behaves similarly to ggplot2::coord_trans()
in that it
occurs after statistical transformation and will affect the visual appearance
of geoms. The main difference is that it takes a single transformer that is
applied to the x and y axes simultaneously. Any transformers produced by
ggforce::linear_trans()
that have x and y arguments should work, but any
other transformers produced using scales::trans_new()
that take x and y
arguments should also work. Axis limits will be adjusted to account for
transformation unless limits are specified with xlim
or ylim
.
Usage
coord_trans_xy(
trans = NULL,
xlim = NULL,
ylim = NULL,
expand = FALSE,
default = FALSE,
clip = "on"
)
Arguments
trans |
Transformer for x and y axes. |
xlim , ylim |
Limits for the x and y axes. |
expand |
If |
default |
Is this the default coordinate system? If |
clip |
Should drawing be clipped to the extent of the plot panel? A
setting of |
Details
This coordinate system only works with geoms where all points are
defined with x and y coordinates (e.g., ggplot2::geom_point()
,
ggplot2::geom_polygon()
). This does not currently work with geoms where
point coordinates are extrapolated (e.g., ggplot2::geom_rect()
).
Furthermore, when used with ggplot2 3.5.0 and later, some transformation
edge cases may cause problems with rendering axis lines. This includes not
currently support "capping" axes. I hope to support all of these geoms,
edge cases, and features in the future.
Examples
# make transformer
library(ggforce)
trans <- linear_trans(shear(2, 0), rotate(-pi / 3))
# set up data to be plotted
square <- data.frame(x = c(0, 0, 4, 4), y = c(0, 1, 1, 0))
points <- data.frame(x = runif(100, 0, 4), y = runif(100, 0, 1))
# plot data normally
library(ggplot2)
ggplot(data = points, aes(x = x, y = y)) +
geom_polygon(data = square, fill = NA, color = "black") +
geom_point(color = "black") +
coord_cartesian(expand = FALSE) +
theme_classic()
# plot data with transformation
ggplot(data = points, aes(x = x, y = y)) +
geom_polygon(data = square, fill = NA, color = "black") +
geom_point(color = "black") +
coord_trans_xy(trans = trans, expand = FALSE) +
theme_classic()
Disparity through time plot using lattice
Description
Plots points on 2-D surfaces within a a 3-D framework. See
lattice::wireframe()
and lattice::panel.cloud()
for customization
options.
Usage
disparity_through_time(
x,
data,
groups,
pch = 16,
col.point = c("blue"),
scales = list(arrows = FALSE, distance = 1, col = "black", z = list(rot = 90)),
colorkey = FALSE,
screen = list(z = 90, x = 70, y = 180),
aspect = c(1.5, 4),
drape = TRUE,
col.regions = c("white"),
alpha.regions = c(1),
perspective = FALSE,
R.mat = matrix(c(1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1), 4, 4),
par.settings = list(axis.line = list(col = "transparent"), layout.heights =
list(top.padding = 0, main.key.padding = 0, key.axis.padding = 0, axis.xlab.padding =
0, xlab.key.padding = 0, key.sub.padding = 0, bottom.padding = 0), layout.widths =
list(left.padding = 0, key.ylab.padding = 0, ylab.axis.padding = 0, axis.key.padding
= 0, right.padding = 0)),
lattice.options = list(axis.padding = list(factor = 0)),
...
)
Arguments
x |
a formula (most likely of the form |
data |
a data frame in which variables in the formula are to be evaluated |
groups |
a variable in |
pch |
the point type |
col.point |
color(s) for points on surfaces |
scales |
a list specifying how the axes are drawn (see
|
colorkey |
logical, should a legend be drawn (or a list describing the
legend; see |
screen |
a list of the rotations that should be applied to each axis |
aspect |
a numeric vector of length 2, giving the relative aspects of the y-size/x-size and z-size/x-size of the enclosing cube |
drape |
logical, whether the surfaces should be colored based on
|
col.regions |
color(s) for surfaces |
alpha.regions |
alpha value(s) for surfaces |
perspective |
logical, whether to plot a perspective view |
R.mat |
a transformational matrix that is applied to the orientation of the axes |
par.settings |
plotting settings (see |
lattice.options |
lattice settings (see |
... |
Other arguments passed to |
Value
An object of class "trellis"
, as output by lattice::wireframe()
.
Examples
g <- data.frame(
x = runif(100, 0, 60), y = runif(100, 0, 10),
z = factor(rep(periods$name[1:5], each = 20),
levels = periods$name[1:5]
)
)
disparity_through_time(z ~ x * y,
data = g, groups = z, aspect = c(1.5, 2),
xlim = c(0, 60), ylim = c(0, 10), col.regions = "lightgreen",
col.point = c("red", "blue")
)
Eon data from the International Commission on Stratigraphy (v2024/12)
Description
A dataset containing the boundary ages, abbreviations, and colors for the eons of the Geologic Time Scale. Based on The ICS International Chronostratigraphic Chart (v2024/12), by Cohen, Finney, Gibbard, and Fan.
Usage
eons
Format
A data frame with 3 rows and 5 variables:
- name
eon name
- max_age
maximum age, in millions of years
- min_age
minimum age, in millions of years
- abbr
eon name abbreviations
- color
the colors for each eon, according to the Commission for the Geological Map of the World
- lab_color
the label colors for each eon, either white or black, whichever has better contrast with the background color, based on recommendations by the International Telecommunication Union
Source
https://stratigraphy.org via https://macrostrat.org/api/v2/defs/intervals?timescale=international%20eons
See Also
Other built-in timescales:
epochs
,
eras
,
periods
,
stages
Epoch data from the International Commission on Stratigraphy (v2024/12)
Description
A dataset containing the boundary ages, abbreviations, and colors for the epochs of the Geologic Time Scale. Based on The ICS International Chronostratigraphic Chart (v2024/12), by Cohen, Finney, Gibbard, and Fan.
Usage
epochs
Format
A data frame with 34 rows and 5 variables:
- name
epoch name
- max_age
maximum age, in millions of years
- min_age
minimum age, in millions of years
- abbr
epoch name abbreviations
- color
the colors for each epoch, according to the Commission for the Geological Map of the World
- lab_color
the label colors for each epoch, either white or black, whichever has better contrast with the background color, based on recommendations by the International Telecommunication Union
Source
https://stratigraphy.org via https://macrostrat.org/api/v2/defs/intervals?timescale=international%20epochs
See Also
Other built-in timescales:
eons
,
eras
,
periods
,
stages
Era data from the International Commission on Stratigraphy (v2024/12)
Description
A dataset containing the boundary ages, abbreviations, and colors for the eras of the Geologic Time Scale. Based on The ICS International Chronostratigraphic Chart (v2024/12), by Cohen, Finney, Gibbard, and Fan.
Usage
eras
Format
A data frame with 10 rows and 5 variables:
- name
era name
- max_age
maximum age, in millions of years
- min_age
minimum age, in millions of years
- abbr
era name abbreviations
- color
the colors for each era, according to the Commission for the Geological Map of the World
- lab_color
the label colors for each era, either white or black, whichever has better contrast with the background color, based on recommendations by the International Telecommunication Union
Source
https://stratigraphy.org via https://macrostrat.org/api/v2/defs/intervals?timescale=international%20eras
See Also
Other built-in timescales:
eons
,
epochs
,
periods
,
stages
Lay out panels in a grid with colored strips
Description
facet_grid_color
behaves similarly to ggplot2::facet_grid()
in that it
forms a matrix of panels defined by row and column faceting variables. The
main difference is that it also allows the user to specify the background and
label colors of the individual facet strips using the colors
and
lab_colors
arguments. If you have only one variable with many levels, try
facet_wrap_color()
.
Usage
facet_grid_color(
colors,
rows = NULL,
cols = NULL,
scales = "fixed",
space = "fixed",
shrink = TRUE,
labeller = "label_value",
lab_colors = "auto",
as.table = TRUE,
switch = NULL,
drop = TRUE,
margins = FALSE,
axes = "margins",
axis.labels = "all"
)
facet_grid_geo(
colors = stages,
rows = NULL,
cols = NULL,
scales = "fixed",
space = "fixed",
shrink = TRUE,
labeller = "label_value",
lab_colors = "auto",
as.table = TRUE,
switch = NULL,
drop = TRUE,
margins = FALSE,
axes = "margins",
axis.labels = "all"
)
Arguments
colors |
Specifies which colors to use to replace the strip backgrounds.
Either A) a function that returns a color for a given strip label, B) the
character name of a function that does the same, C) a named character
vector with names matching strip labels and values indicating the desired
colors, or D) a data.frame representing a lookup table with columns named
"name" (matching strip labels) and "color" (indicating desired colors). If
the function returns |
rows , cols |
A set of variables or expressions quoted by
For compatibility with the classic interface, |
scales |
Are scales shared across all facets (the default,
|
space |
If |
shrink |
If |
labeller |
A function that takes one data frame of labels and
returns a list or data frame of character vectors. Each input
column corresponds to one factor. Thus there will be more than
one with |
lab_colors |
Specifies which colors to use for the strip labels. Either
A) a function that returns a color for a given strip label, B) the
character name of a function that does the same, C) a named character
vector with names matching strip labels and values indicating the desired
colors, D) a data.frame representing a lookup table with columns named
"name" (matching strip labels) and "lab_color" (indicating desired colors),
or E) "auto" (the default), which set the labels to black or white,
whichever has better contrast with the background color, based on
recommendations by the International Telecommunication Union.
If the function returns |
as.table |
If |
switch |
By default, the labels are displayed on the top and
right of the plot. If |
drop |
If |
margins |
Either a logical value or a character
vector. Margins are additional facets which contain all the data
for each of the possible values of the faceting variables. If
|
axes |
Determines which axes will be drawn. When |
axis.labels |
Determines whether to draw labels for interior axes when
the |
Details
facet_grid_geo(...)
is an alias of facet_grid_color()
with the default of
colors
set to stages
.
See Also
Other faceting functions:
facet_nested_color()
,
facet_nested_wrap_color()
,
facet_wrap_color()
Examples
library(ggplot2)
df <- data.frame(x = 1:10, y = 1:10, period = c("Permian", "Triassic"))
ggplot(df) +
geom_point(aes(x, y)) +
facet_grid_color(cols = vars(period), colors = periods)
Layout panels in a grid with nested colored strips
Description
facet_nested_color
behaves similarly to ggh4x::facet_nested()
in that it
forms a matrix of panels defined by row and column faceting variables and
nests grouped facets. The main difference is that it also allows the user to
specify the background and label colors of the individual facet strips using
the colors
and lab_colors
arguments.
Usage
facet_nested_color(
colors,
rows = NULL,
cols = NULL,
scales = "fixed",
space = "fixed",
axes = "margins",
remove_labels = "none",
independent = "none",
shrink = TRUE,
labeller = "label_value",
lab_colors = "auto",
as.table = TRUE,
switch = NULL,
drop = TRUE,
margins = FALSE,
nest_line = element_line(inherit.blank = TRUE),
solo_line = FALSE,
resect = unit(0, "mm"),
render_empty = TRUE,
strip = strip_nested(),
bleed = NULL
)
facet_nested_geo(
colors = rbind(periods, stages),
rows = NULL,
cols = NULL,
scales = "fixed",
space = "fixed",
axes = "margins",
remove_labels = "none",
independent = "none",
shrink = TRUE,
labeller = "label_value",
lab_colors = "auto",
as.table = TRUE,
switch = NULL,
drop = TRUE,
margins = FALSE,
nest_line = element_line(inherit.blank = TRUE),
solo_line = FALSE,
resect = unit(0, "mm"),
render_empty = TRUE,
strip = strip_nested(),
bleed = NULL
)
Arguments
colors |
Specifies which colors to use to replace the strip backgrounds.
Either A) a function that returns a color for a given strip label, B) the
character name of a function that does the same, C) a named character
vector with names matching strip labels and values indicating the desired
colors, or D) a data.frame representing a lookup table with columns named
"name" (matching strip labels) and "color" (indicating desired colors). If
the function returns |
rows , cols |
A set of variables or expressions quoted by
For compatibility with the classic interface, |
scales |
A
|
space |
A
|
axes |
A
|
remove_labels |
A
|
independent |
A
|
shrink |
If |
labeller |
A function that takes one data frame of labels and
returns a list or data frame of character vectors. Each input
column corresponds to one factor. Thus there will be more than
one with |
lab_colors |
Specifies which colors to use for the strip labels. Either
A) a function that returns a color for a given strip label, B) the
character name of a function that does the same, C) a named character
vector with names matching strip labels and values indicating the desired
colors, D) a data.frame representing a lookup table with columns named
"name" (matching strip labels) and "lab_color" (indicating desired colors),
or E) "auto" (the default), which set the labels to black or white,
whichever has better contrast with the background color, based on
recommendations by the International Telecommunication Union.
If the function returns |
as.table |
If |
switch |
By default, the labels are displayed on the top and
right of the plot. If |
drop |
If |
margins |
Either a logical value or a character
vector. Margins are additional facets which contain all the data
for each of the possible values of the faceting variables. If
|
nest_line |
a theme element, either |
solo_line |
A |
resect |
a |
render_empty |
A |
strip |
An object created by a call to a strip function, such as
|
bleed |
|
Details
facet_nested_geo(...)
is an alias of facet_nested_color()
with the
default of colors
set to rbind(periods, stages)
.
See Also
Other faceting functions:
facet_grid_color()
,
facet_nested_wrap_color()
,
facet_wrap_color()
Examples
library(ggplot2)
df <- data.frame(x = 1:10, y = 1:10,
period = factor(c("Permian", "Triassic", "Jurassic",
"Cretaceous", "Paleogene"),
levels = c("Permian", "Triassic",
"Jurassic", "Cretaceous",
"Paleogene")),
era = factor(c("Paleozoic", "Mesozoic", "Mesozoic",
"Mesozoic", "Cenozoic"),
levels = c("Paleozoic", "Mesozoic",
"Cenozoic")))
ggplot(df, aes(x, y)) +
geom_point() +
facet_nested_color(~ era + period, colors = rbind(periods, eras))
Ribbon of panels with nested colored strips
Description
facet_nested_wrap_color
behaves similarly to ggh4x::facet_nested_wrap()
in that it wraps a sequence of panels onto a two-dimensional layout, and
nests grouped facets where possible.. The main difference is that it also
allows the user to specify the background and label colors of the individual
facet strips using the colors
and lab_colors
arguments.
Usage
facet_nested_wrap_color(
facets,
colors,
nrow = NULL,
ncol = NULL,
scales = "fixed",
axes = "margins",
remove_labels = "none",
shrink = TRUE,
labeller = "label_value",
lab_colors = "auto",
as.table = TRUE,
drop = TRUE,
dir = "h",
strip.position = "top",
nest_line = element_line(inherit.blank = TRUE),
solo_line = FALSE,
resect = unit(0, "mm"),
trim_blank = TRUE,
strip = strip_nested(),
bleed = NULL
)
facet_nested_wrap_geo(
facets,
colors = rbind(periods, stages),
nrow = NULL,
ncol = NULL,
scales = "fixed",
axes = "margins",
remove_labels = "none",
shrink = TRUE,
labeller = "label_value",
lab_colors = "auto",
as.table = TRUE,
drop = TRUE,
dir = "h",
strip.position = "top",
nest_line = element_line(inherit.blank = TRUE),
solo_line = FALSE,
resect = unit(0, "mm"),
trim_blank = TRUE,
strip = strip_nested(),
bleed = NULL
)
Arguments
facets |
A set of variables or expressions quoted by For compatibility with the classic interface, can also be a
formula or character vector. Use either a one sided formula, |
colors |
Specifies which colors to use to replace the strip backgrounds.
Either A) a function that returns a color for a given strip label, B) the
character name of a function that does the same, C) a named character
vector with names matching strip labels and values indicating the desired
colors, or D) a data.frame representing a lookup table with columns named
"name" (matching strip labels) and "color" (indicating desired colors). If
the function returns |
nrow , ncol |
Number of rows and columns. |
scales |
A
|
axes |
A
|
remove_labels |
A
|
shrink |
If |
labeller |
A function that takes one data frame of labels and
returns a list or data frame of character vectors. Each input
column corresponds to one factor. Thus there will be more than
one with |
lab_colors |
Specifies which colors to use for the strip labels. Either
A) a function that returns a color for a given strip label, B) the
character name of a function that does the same, C) a named character
vector with names matching strip labels and values indicating the desired
colors, D) a data.frame representing a lookup table with columns named
"name" (matching strip labels) and "lab_color" (indicating desired colors),
or E) "auto" (the default), which set the labels to black or white,
whichever has better contrast with the background color, based on
recommendations by the International Telecommunication Union.
If the function returns |
as.table |
If |
drop |
If |
dir |
Direction: either |
strip.position |
By default, the labels are displayed on the top of
the plot. Using |
nest_line |
a theme element, either |
solo_line |
A |
resect |
a |
trim_blank |
A |
strip |
An object created by a call to a strip function, such as
|
bleed |
|
Details
facet_nested_wrap_geo(...)
is an alias of facet_nested_wrap_color()
with the
default of colors
set to rbind(periods, stages)
.
See Also
Other faceting functions:
facet_grid_color()
,
facet_nested_color()
,
facet_wrap_color()
Examples
library(ggplot2)
df <- data.frame(x = 1:10, y = 1:10,
period = factor(c("Permian", "Triassic", "Jurassic",
"Cretaceous", "Paleogene"),
levels = c("Permian", "Triassic",
"Jurassic", "Cretaceous",
"Paleogene")),
era = factor(c("Paleozoic", "Mesozoic", "Mesozoic",
"Mesozoic", "Cenozoic"),
levels = c("Paleozoic", "Mesozoic",
"Cenozoic")))
ggplot(df, aes(x, y)) +
geom_point() +
facet_nested_wrap_color(~ era + period, colors = rbind(periods, eras))
Wrap a 1d ribbon of panels into 2d with colored strips
Description
facet_wrap_color
behaves similarly to ggplot2::facet_wrap()
in that it
wraps a 1d sequence of panels into 2d. The main difference is that it also
allows the user to specify the background and label colors of the individual
facet strips using the colors
and lab_colors
arguments. This is generally
a better use of screen space than facet_grid_color()
because most displays
are roughly rectangular.
Usage
facet_wrap_color(
facets,
colors,
nrow = NULL,
ncol = NULL,
scales = "fixed",
shrink = TRUE,
labeller = "label_value",
lab_colors = "auto",
as.table = TRUE,
drop = TRUE,
dir = "h",
strip.position = "top",
axes = "margins",
axis.labels = "all"
)
facet_wrap_geo(
facets,
colors = stages,
nrow = NULL,
ncol = NULL,
scales = "fixed",
shrink = TRUE,
labeller = "label_value",
lab_colors = "auto",
as.table = TRUE,
drop = TRUE,
dir = "h",
strip.position = "top",
axes = "margins",
axis.labels = "all"
)
Arguments
facets |
A set of variables or expressions quoted by For compatibility with the classic interface, can also be a
formula or character vector. Use either a one sided formula, |
colors |
Specifies which colors to use to replace the strip backgrounds.
Either A) a function that returns a color for a given strip label, B) the
character name of a function that does the same, C) a named character
vector with names matching strip labels and values indicating the desired
colors, or D) a data.frame representing a lookup table with columns named
"name" (matching strip labels) and "color" (indicating desired colors). If
the function returns |
nrow , ncol |
Number of rows and columns. |
scales |
Should scales be fixed ( |
shrink |
If |
labeller |
A function that takes one data frame of labels and
returns a list or data frame of character vectors. Each input
column corresponds to one factor. Thus there will be more than
one with |
lab_colors |
Specifies which colors to use for the strip labels. Either
A) a function that returns a color for a given strip label, B) the
character name of a function that does the same, C) a named character
vector with names matching strip labels and values indicating the desired
colors, D) a data.frame representing a lookup table with columns named
"name" (matching strip labels) and "lab_color" (indicating desired colors),
or E) "auto" (the default), which set the labels to black or white,
whichever has better contrast with the background color, based on
recommendations by the International Telecommunication Union.
If the function returns |
as.table |
|
drop |
If |
dir |
Direction: either |
strip.position |
By default, the labels are displayed on the top of
the plot. Using |
axes |
Determines which axes will be drawn in case of fixed scales.
When |
axis.labels |
Determines whether to draw labels for interior axes when
the scale is fixed and the |
Details
facet_wrap_geo(...)
is an alias of facet_wrap_color()
with the default of
colors
set to stages
.
See Also
Other faceting functions:
facet_grid_color()
,
facet_nested_color()
,
facet_nested_wrap_color()
Examples
library(ggplot2)
df <- data.frame(x = 1:10, y = 1:10, period = c("Permian", "Triassic"))
ggplot(df) +
geom_point(aes(x, y)) +
facet_wrap_color(vars(period), colors = periods)
Get a FGDC geologic plotting pattern
Description
Retrieve a single geologic pattern as defined in the FGDC Digital Cartographic Standard for Geologic Map Symbolization by the U.S. Geological Survey and the Geologic Data Subcommittee (GDS) of the Federal Geographic Data Committee (FGDC).
Usage
geo_pattern(
code,
scale = 2,
col = NULL,
fill = NULL,
alpha = NULL,
bg = "white"
)
geo_grob(code, col = NULL, fill = NULL, alpha = NULL, bg = "white")
Arguments
code |
The number corresponding to the pattern to return. Strings and numbers are permitted. |
scale |
The visual scale of the pattern (higher values mean the pattern is more zoomed in). |
col |
The color to use for the lines of the pattern. |
fill |
The color used to fill various closed shapes (e.g., circles) in the pattern. |
alpha |
The transparency to use for the fill of the pattern. |
bg |
The background color to use for the pattern. |
Details
For specific codes, see the "pattern numbers" in the full pattern chart
for valid code
values. Daven Quinn has also assembled more accessible
documentation of the map patterns/codes
and lithology patterns/codes.
rmacrostrat::def_lithologies()
can also be used to look up pattern codes
for various lithologies (see the "fill" column). Note that codes associated
with color variants (e.g., "101-M") are supported but will result in the
default color variant instead (usually black and white, e.g., "101-K").
These patterns were originally processed and optimized by Daven Quinn and are hosted on GitHub.
Value
geo_grob()
returns a grob object with a single
instance of the desired pattern. geo_pattern()
returns a
GridPattern object with a repeated instance of the
desired pattern.
See Also
FGDC patterns:
grid.pattern_geo()
,
scale_fill_geopattern()
Examples
library(grid)
# Get a generic igneous pattern
pattern1 <- geo_pattern(code = "313-K")
# Get the pattern for a sandstone
pattern2 <- geo_pattern(code = "607")
# plot the two patterns
grid.newpage()
grid.draw(rectGrob(gp = gpar(fill = pattern1)))
grid.newpage()
grid.draw(rectGrob(gp = gpar(fill = pattern2)))
Plot a 2-D phylomorphospace in ggplot2
Description
This behaves similar to phytools::phylomorphospace()
, but is for plotting a
2-D phylomorphospace with ggplot2::ggplot()
. This function works like any
other ggplot2
geom; it can be combined with other geoms (see the example
below), and the output can be modified using scales, themes, etc.
Usage
geom_phylomorpho(
tree,
mapping = NULL,
data = NULL,
position = "identity",
...,
seg_args = list(),
point_args = list(),
arrow = NULL,
arrow.fill = NULL,
lineend = "butt",
linejoin = "round",
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
Arguments
tree |
An object of class "phylo". |
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A 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 both |
seg_args |
A list of arguments passed only to |
point_args |
A list of arguments passed only to |
arrow |
specification for arrow heads, as created by |
arrow.fill |
fill colour to use for the arrow head (if closed). |
lineend |
Line end style (round, butt, square). |
linejoin |
Line join style (round, mitre, bevel). |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
Details
The ancestral states are estimated using phytools::fastAnc()
. Note that
phytools
is not necessarily installed with deeptime
, but it is required
to use this function. Following the estimation of the ancestral states, the
nodes are connected using ggplot2::geom_segment()
, while the tips are
indicated using ggplot2::geom_point()
.
The default expectation is that the order of the data is the same order as
the tip labels of the tree (tree$tip.label
). However, if this is not the
case, you can map the optional label
aesthetic to a column in the data that
contains the tip names (see example below).
Examples
library(ggplot2)
library(ape)
tr <- rtree(10)
dat <- data.frame(
x = runif(10), y = runif(10), label = tr$tip.label,
row.names = tr$tip.label
)
ggplot(dat, aes(x = x, y = y, label = label)) +
geom_phylomorpho(tr) +
geom_label(size = 5)
Display points and their range
Description
This geom is like ggplot2::geom_pointrange()
in that it draws points and
lines. However, unlike ggplot2::geom_pointrange()
, this geom takes in sets
of x-y points and calculates the ranges/intervals based on those. It then
plots both the original points and the ranges using
ggplot2::geom_linerange()
. In cases where not all points are connected
(because of grouping due to aesthetics), the background_line
argument can
be used to add lines that span the entire point range for each x
or y
category.
Usage
geom_points_range(
mapping = NULL,
data = NULL,
stat = "points_range",
position = "identity",
...,
na.rm = FALSE,
orientation = NA,
background_line = NULL,
show.legend = NA,
inherit.aes = TRUE
)
stat_points_range(
mapping = NULL,
data = NULL,
geom = "points_range",
position = "identity",
...,
na.rm = FALSE,
orientation = NA,
show.legend = NA,
inherit.aes = TRUE
)
Arguments
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
|
... |
Arguments passed on to both |
na.rm |
If |
orientation |
The orientation of the layer. The default ( |
background_line |
A named list of aesthetic values to use for plotted
line segments that span the entire |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
geom |
The geometric object to use to display the data for this layer.
When using a
|
Aesthetics
geom_points_range()
understands the following
aesthetics (required aesthetics are in bold):
-
x
-
y
size
color/colour
fill
shape
alpha
group
linetype
linewidth
Computed variables
These are calculated by the 'stat' part of
layers and can be accessed with delayed evaluation.
stat_points_range()
provides the following variables, some of which
depend on the orientation:
-
after_stat(ymin)
orafter_stat(xmin)
the minimum extent of the point range -
after_stat(ymax)
orafter_stat(xmax)
the maximum extent of the point range
Orientation
This geom treats each axis differently and, thus, can thus have two orientations. Often the orientation is easy to deduce from a combination of the given mappings and the types of positional scales in use. Thus, ggplot2 will by default try to guess which orientation the layer should have. Under rare circumstances, the orientation is ambiguous and guessing may fail. In that case the orientation can be specified directly using the orientation
parameter, which can be either "x"
or "y"
. The value gives the axis that the geom should run along, "x"
being the default orientation you would expect for the geom.
Examples
library(ggplot2)
library(palaeoverse)
data(tetrapods)
tetrapod_names <- tetrapods$accepted_name[1:50]
beds_sampled <- sample.int(n = 10, size = 50, replace = TRUE)
occdf <- data.frame(taxon = tetrapod_names, bed = beds_sampled)
ggplot(occdf, aes(y = reorder(taxon, bed, min), x = bed)) +
geom_points_range()
Label nodes on a phylogenetic tree plotted with ggtree
Description
This geom adds labels to all or a subset of the nodes of a phylogenetic tree
that has been plotted using ggtree::ggtree()
. It is therefore very similar
to ggtree::geom_tiplab()
, ggtree::geom_tiplab2()
,
ggtree::geom_nodelab()
, and ggtree::geom_nodelab2()
. However, unlike
those geoms, this geom is intended to work with all coordinate systems,
including coord_geo()
and coord_geo_radial()
.
Usage
geom_text_phylo(
mapping = NULL,
data = NULL,
stat = "identity",
position = "identity",
...,
parse = FALSE,
nudge_x = 0,
nudge_y = 0,
node_type = "tip",
auto_adjust = TRUE,
check_overlap = FALSE,
size.unit = "mm",
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
Arguments
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
|
parse |
If |
nudge_x , nudge_y |
Horizontal and vertical adjustment to nudge labels by.
Useful for offsetting text from points, particularly on discrete scales.
Cannot be jointly specified with |
node_type |
Determines the subset of nodes to label. Valid options are "tip" for tip nodes, "internal" for non-tip nodes, and "all" for all nodes. |
auto_adjust |
Should upside-down text labels automatically be rotated 180° to improve readability? |
check_overlap |
If |
size.unit |
How the |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
Details
Each label will be plotted with the same angle as the branch/edge leading to
its node by default. The angle
, hjust
, and vjust
aesthetics can be used
to adjust this. If custom angle
values are specified, these will be
added to the default angle as calculated as described above.
As with ggplot2::geom_text()
, the limits of axes will not be
expanded to accommodate the new labels, so you may need to extend them
manually using the limits
or expand
arguments within scale_
or coord_
functions. Note that coord_geo()
by default sets expand = FALSE
.
Aesthetics
geom_text_phylo()
understands the following
aesthetics (required aesthetics are in bold):
-
x (pulled from the phylogeny by default)
-
y (pulled from the phylogeny by default)
-
label (pulled from the phylogeny by default)
alpha
angle
color/colour
family
fontface
group
hjust
lineheight
size
vjust
Alignment
You can modify text alignment with the vjust
and hjust
aesthetics. These can either be a number between 0 (left/bottom) and
1 (right/top) or a character ("left"
, "middle"
, "right"
, "bottom"
,
"center"
, "top"
). There are two special alignments: "inward"
and
"outward"
. Inward always aligns text towards the center, and outward
aligns it away from the center.
Examples
library(ggplot2)
library(ape)
library(ggtree)
tr <- rtree(10)
revts(ggtree(tr)) +
geom_text_phylo() +
coord_geo_radial("epochs")
Get geological timescale data
Description
getScaleData()
was renamed to get_scale_data()
as of deeptime version
1.0.0 to create a more consistent API.
Usage
getScaleData(name)
Get geological timescale data
Description
This function takes a name of a geological timescale and returns data for the
timescale. Valid names include those of built-in data.frames
(periods()
,
epochs()
, stages()
, eons()
, or eras()
), partial matches of those
names (e.g., "per" or "age"), and partial or exact matches to those hosted
by Macrostrat (see Details below). Note that the colors in the built-in
data.frames
are according to the Commission for the Geological Map of the
World. If you would like to obtain custom Macrostrat colors that are better
for mapping, you should specify the full name of a timescale (e.g.,
"international periods") and set true_colors
to FALSE
. Note that these
colors only vary for the Precambrian.
Usage
get_scale_data(name, true_colors = TRUE)
Arguments
name |
The name of the desired timescale. |
true_colors |
Return original international time scale colors? (as opposed to custom Macrostrat plotting colors) |
Details
The following timescales are available from the Macrostrat API as of 2025-06-18:
international ages
international epochs
international periods
calcareous nannoplankton zones
New Zealand ages
custom COSUNA
North American land mammal ages
international intervals
COSUNA
international eras
international eons
Trilobite Zonation - Laurentia
Conodont Zonation
North American Regional
Ammonite Zonation - Boreal
Ammonite Zonation - Western Interior
international intervals covering all time
Scotese Reconstruction
Geomagnetic Polarity Chron
Geomagnetic Polarity Subchron
Planktic foraminiferal Primary Biozones
Planktic foraminiferal Secondary Biozones
Planktic foraminiferal datums
Martian Periods
Martian Epochs
Cretaceous Planktic foraminifer zonations
Low latitude radiolarian zonation
Neogene North Pacific Diatom Biochronology
Neogene North Pacific Diatom Biochronology Subzones
Siberian Regional
Australian Regional
Western Europe Regional
Russian Platform Regional Stages
Russian Precambrian Eras
Russian Precambrian Eons
Russian Epochs
Russian Stages
The most up-to-date list can be found via the Macrostrat API here.
Value
A data.frame
with the following columns:
name |
the names of the time intervals |
max_age |
the oldest boundaries of the time intervals, in millions of years |
min_age |
the youngest boundaries of the time intervals, in millions of years |
abbr |
either traditional abbreviations of the names of the time intervals (if they exist) or custom abbreviations created with R |
color |
hex color codes associated with the time intervals (if applicable) |
lab_color |
default label colors for the time interals, either white or black, whichever has better contrast with the background color, based on recommendations by the International Telecommunication Union |
Combine and arrange multiple ggplot-like objects
Description
Arrange multiple ggplot, grobified ggplot, or geo_scale objects on a page, aligning the plot panels, axes, and axis titles.
Usage
ggarrange2(
...,
plots = list(...),
layout = NULL,
nrow = NULL,
ncol = NULL,
widths = NULL,
heights = NULL,
byrow = TRUE,
top = NULL,
bottom = NULL,
left = NULL,
right = NULL,
padding = unit(0.5, "line"),
margin = unit(0.5, "line"),
clip = "on",
draw = TRUE,
newpage = TRUE,
debug = FALSE,
labels = NULL,
label.args = list(gp = gpar(font = 4, cex = 1.2))
)
Arguments
... |
ggplot, grobified ggplot (gtable), or geo_scale objects |
plots |
list of ggplot, gtable, or geo_scale objects |
layout |
a matrix of integers specifying where each plot should go, like
|
nrow |
number of rows |
ncol |
number of columns |
widths |
list of requested widths |
heights |
list of requested heights |
byrow |
logical, fill by rows |
top |
optional string, or grob |
bottom |
optional string, or grob |
left |
optional string, or grob |
right |
optional string, or grob |
padding |
unit of length one, margin around annotations |
margin |
vector of units of length 4: top, right, bottom, left (as in
|
clip |
argument of gtable |
draw |
logical: draw or return a grob |
newpage |
logical: draw on a new page |
debug |
logical, show layout with thin lines |
labels |
character labels used for annotation of subfigures (should be
in the same order as |
label.args |
label list of parameters for the formatting of labels |
Value
gtable of aligned plots
Examples
library(ggplot2)
p1 <- ggplot(mtcars, aes(mpg, wt, colour = factor(cyl))) +
geom_point()
p2 <- ggplot(mtcars, aes(mpg, wt, colour = factor(cyl))) +
geom_point() +
facet_wrap(~cyl, ncol = 2, scales = "free") +
guides(colour = "none") +
theme()
ggarrange2(p1, p2, widths = c(2, 1), labels = c("a", "b"))
p3 <- ggplot() +
geom_point(aes(y = runif(1000, 0, 8), x = runif(1000, 0, 1000))) +
scale_x_reverse() +
coord_geo(xlim = c(1000, 0), ylim = c(0, 8)) +
theme_classic()
ggarrange2(ggarrange2(p1, p2, widths = c(2, 1), draw = FALSE), p3, nrow = 2)
Add a geologic scale below ggplots using grid
Description
This function takes a ggplot object and adds a geologic time scale at the specified side using the grid and gtable packages.
If custom data is provided (with dat
), it should consist of at least 3
columns of data. See data(periods)
for an example.
The
name
column lists the names of each time interval. These will be used as labels if no abbreviations are provided.The
max_age
column lists the oldest boundary of each time interval.The
min_age
column lists the youngest boundary of each time interval.The
abbr
column is optional and lists abbreviations that may be used as labels.The
color
column is also optional and lists a hex color code (which can be obtained withrgb()
) for each time interval.
Usage
gggeo_scale(obj, ...)
## S3 method for class 'gtable'
gggeo_scale(
obj,
lims,
dat = "periods",
fill = NULL,
color = "black",
alpha = 1,
height = unit(2, "line"),
pos = "bottom",
lab = TRUE,
rot = 0,
abbrv = TRUE,
skip = c("Quaternary", "Holocene", "Late Pleistocene"),
size = 5,
lwd = 0.25,
margin = unit(0, "line"),
neg = FALSE,
bord = c("left", "right", "top", "bottom"),
center_end_labels = FALSE,
...
)
## S3 method for class 'ggplot'
gggeo_scale(
obj,
dat = "periods",
fill = NULL,
color = "black",
alpha = 1,
height = unit(2, "line"),
pos = "bottom",
lab = TRUE,
rot = 0,
abbrv = TRUE,
skip = c("Quaternary", "Holocene", "Late Pleistocene"),
size = 5,
lwd = 0.25,
margin = unit(0, "line"),
neg = FALSE,
bord = c("left", "right", "top", "bottom"),
center_end_labels = FALSE,
...
)
## S3 method for class 'geo_scale'
gggeo_scale(
obj,
dat = "periods",
fill = NULL,
color = "black",
alpha = 1,
height = unit(2, "line"),
pos = "bottom",
lab = TRUE,
rot = 0,
abbrv = TRUE,
skip = c("Quaternary", "Holocene", "Late Pleistocene"),
size = 5,
lwd = 0.25,
margin = unit(0, "line"),
neg = FALSE,
bord = c("left", "right", "top", "bottom"),
center_end_labels = FALSE,
...
)
## S3 method for class 'geo_scale'
print(x, ...)
Arguments
obj |
An object of class |
... |
further arguments passed to |
lims |
The limits of the axis of the desired side of the plot. Only required if using a gtable object not created by this function. |
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 dataframe of time interval boundaries (see Details). |
fill |
The fill color of the boxes. The default is to use the colors
included in |
color |
The outline color of the interval boxes. |
alpha |
The transparency of the fill colors. |
height |
The height (or width if |
pos |
Which side to add the scale to (left, right, top, or bottom). First letter may also be used. |
lab |
Whether to include labels. |
rot |
The amount of counter-clockwise rotation to add to the labels (in degrees). |
abbrv |
If including labels, whether to use abbreviations instead of full interval names. |
skip |
A vector of interval names indicating which intervals should not be labeled. |
size |
Label size. |
lwd |
Line width. |
margin |
The width of the margin around the returned object (can be a vector of length 4). |
neg |
Set this to true if your x-axis is using negative values. |
bord |
A vector specifying on Which sides of the scale to add borders
(same options as |
center_end_labels |
Should labels be centered within the visible range of intervals at the ends of the axis? |
x |
An object of class geo_scale. |
Value
A geo_scale object. Basically a gtable object but with the axis limits included.
Life cycle
This function is deprecated in favor of coord_geo()
as of deeptime
version 1.0.0. It will be removed in a future release.
Examples
library(ggplot2)
# bottom scale by default
p <- ggplot() +
geom_point(aes(y = runif(1000, 0, 8), x = runif(1000, 0, 1000))) +
scale_x_reverse() +
coord_cartesian(xlim = c(1000, 0), ylim = c(0, 8), expand = FALSE) +
theme_classic()
gggeo_scale(p)
# can specify any side of the plot
p <- ggplot() +
geom_point(aes(x = runif(1000, 0, 8), y = runif(1000, 0, 1000))) +
scale_y_reverse() +
coord_cartesian(xlim = c(0, 8), ylim = c(1000, 0), expand = FALSE) +
theme_classic()
gggeo_scale(p, pos = "left", rot = 90)
# can add multiple scales
p <- ggplot() +
geom_point(aes(y = runif(1000, 0, 8), x = runif(1000, 0, 100))) +
scale_x_reverse() +
coord_cartesian(xlim = c(100, 0), ylim = c(0, 8), expand = FALSE) +
theme_classic()
p <- gggeo_scale(p, abbrv = FALSE)
p <- gggeo_scale(p, dat = "epochs", height = unit(4, "lines"), rot = 90,
size = 2.5, abbrv = FALSE)
gggeo_scale(p, dat = "stages", height = unit(4, "lines"), rot = 90,
size = 2.5, abbrv = FALSE)
## Not run:
# intervals on both sides for different timescales (ICS stages vs North
# American Land Mammal Ages)
p <- ggplot() +
geom_point(aes(x = runif(1000, 0, 10), y = runif(1000, 0, 65))) +
scale_y_reverse() +
coord_cartesian(xlim = c(0, 10), ylim = c(65, 0), expand = FALSE) +
theme_classic()
p <- gggeo_scale(p, dat = "stages", pos = "left", height = unit(4, "lines"),
size = 2.5, abbrv = FALSE)
gggeo_scale(p, dat = "North American Land Mammal Ages",
pos = "right", height = unit(4, "lines"),
size = 2.5, abbrv = FALSE)
## End(Not run)
# can add scales to a faceted plot
# use gggeo_scale_old() if you have more than one column
df <- data.frame(
x = runif(1000, 0, 541), y = runif(1000, 0, 8),
z = sample(c(1, 2, 3, 4), 1000, TRUE)
)
p <- ggplot(df) +
geom_point(aes(x, y)) +
scale_x_reverse() +
coord_cartesian(xlim = c(541, 0), ylim = c(0, 8), expand = FALSE) +
theme_classic() +
facet_wrap(~z, ncol = 1)
gggeo_scale(p)
# can even add a scale to a phylogeny (using ggtree)
library(phytools)
library(ggtree)
tree <- pbtree(b = .03, d = .01, n = 100)
p <- ggtree(tree) +
coord_cartesian(xlim = c(-500, 0), ylim = c(-2, Ntip(tree)),
expand = FALSE) +
scale_x_continuous(breaks = seq(-500, 0, 100),
labels = abs(seq(-500, 0, 100))) +
theme_tree2()
p <- revts(p)
gggeo_scale(p, neg = TRUE)
Add a geologic scale on top of ggplots
Description
This function takes a ggplot object and adds a geologic time scale at the specified side.
Usage
gggeo_scale_old(
gg,
dat = "periods",
fill = NULL,
color = "black",
alpha = 1,
height = 0.05,
gap = 0,
pos = "bottom",
lab = TRUE,
rot = 0,
abbrv = TRUE,
skip = c("Quaternary", "Holocene", "Late Pleistocene"),
size = 5,
neg = FALSE
)
Arguments
gg |
The ggplot object. |
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 dataframe of time interval boundaries (see Details). |
fill |
The fill color of the boxes. The default is to use the colors
included in |
color |
The outline color of the interval boxes. |
alpha |
The transparency of the fill colors. |
height |
The proportional height (or width if |
gap |
The proportional height (or width) of the entire plot to use as a gap between the axis and the scale. |
pos |
Which side to add the scale to (left, right, top, or bottom). First letter may also be used. |
lab |
Whether to include labels. |
rot |
The amount of counter-clockwise rotation to add to the labels (in degrees). |
abbrv |
If including labels, whether to use abbreviations instead of full interval names. |
skip |
A vector of interval names indicating which intervals should not be labeled. |
size |
Label size. |
neg |
Set this to true if your x-axis is using negative values. |
Details
If custom data is provided (with dat
), it should consist of at least 3
columns of data. See data(periods)
for an example.
The
name
column lists the names of each time interval. These will be used as labels if no abbreviations are provided.The
max_age
column lists the oldest boundary of each time interval.The
min_age
column lists the youngest boundary of each time interval.The
abbr
column is optional and lists abbreviations that may be used as labels.The
color
column is also optional and lists a hex color code (which can be obtained withrgb()
) for each time interval.
Value
A ggplot object.
Life cycle
This function is fully deprecated in favor of coord_geo()
as of
deeptime version 1.2.0. It will be removed in a future version.
Plot an individual FGDC pattern using grid
Description
This function can be used to plot a single geologic pattern as defined in the
FGDC Digital Cartographic Standard for Geologic Map Symbolization by the U.S. Geological Survey and the Geologic Data Subcommittee (GDS) of the Federal Geographic Data Committee (FGDC). The pattern is plotted on the
existing canvas (i.e., use grid::grid.newpage()
to make a new canvas).
Usage
grid.pattern_geo(params, boundary_df, aspect_ratio, legend = FALSE)
Arguments
params |
A list of pattern parameters to customize the plotted pattern (see "Details"). |
boundary_df |
A |
aspect_ratio |
Unused. |
legend |
Unused. |
Details
The following params
are accepted:
pattern_alpha
Alpha transparency for pattern. default: 1
pattern_colour
Color used for strokes and points in the pattern. default: 'black'
pattern_fill
Color used to fill various closed shapes (e.g., circles) in the pattern. default:
NA
pattern_scale
Scale. default: 2
pattern_type
Code for the FGDC pattern to use. See
geo_pattern()
for more details. default: "101"fill
Color used for the background. default: "white"
Warning
Pattern fills are not supported on all graphics devices.
Not all devices are under active development, and such devices are unlikely
to add support for new features (such as pattern fills). The new features
have only been implemented on a subset of graphics devices so far:
cairo_pdf()
, cairo_ps()
, x11(type="cairo")
,
png(type="cairo")
,
jpeg(type="cairo")
,
tiff(type="cairo")
, svg()
, and pdf()
. Although
there is no support yet for quartz()
or windows()
, almost all of the
graphics devices above will work on all major platforms. Further, the
ragg and
svglite packages contain graphics
devices that support patterns. When using a graphics device where patterns
are not supported, closed shapes will be rendered with a transparent fill.
Note that, at least on Windows machines, the default device in RStudio and
in the knitr package is png()
, which does not support patterns. In
RStudio, you can go to ‘Tools > Global Options > General > Graphics’ and
choose the ‘Cairo PNG’ device from the dropdown menu to display patterns.
Similar issues may arise when using RStudio on other operating systems.
See Also
FGDC patterns:
geo_pattern()
,
scale_fill_geopattern()
Examples
# use the function directly to make a hexagon with the pattern
library(grid)
x <- 0.5 + 0.5 * cos(seq(2 * pi / 4, by = 2 * pi / 6, length.out = 6))
y <- 0.5 + 0.5 * sin(seq(2 * pi / 4, by = 2 * pi / 6, length.out = 6))
grid.newpage()
grid.pattern_geo(params = list(pattern_type = "633", pattern_scale = 4),
boundary_df = data.frame(x, y, id = 1))
# use the function via ggpattern by specifying `pattern = 'geo'`
library(ggplot2)
library(ggpattern)
df <- data.frame(trt = c("a", "b", "c"), outcome = c(2.3, 1.9, 3.2))
ggplot(df, aes(trt, outcome)) +
geom_col_pattern(aes(color = trt, pattern_type = trt), pattern = 'geo',
pattern_color = "black", fill = "white", pattern_fill = "white") +
scale_pattern_type_manual(values = c("101", "313", "634")) +
scale_color_viridis_d() +
theme(legend.key.size = unit(1.5, 'cm'))
Decompose a ggplot gtable
Description
Reformat the gtable associated with a ggplot object into a 7x7 gtable where the central cell corresponds to the plot panel(s), the rectangle of cells around that corresponds to the axes, and the rectangle of cells around that corresponds to the axis titles.
Usage
gtable_frame2(
g,
width = unit(1, "null"),
height = unit(1, "null"),
debug = FALSE
)
Arguments
g |
gtable |
width |
requested width |
height |
requested height |
debug |
logical draw gtable cells |
Value
7x7 gtable wrapping the plot
Examples
library(grid)
library(gridExtra)
library(ggplot2)
p1 <- ggplot(mtcars, aes(mpg, wt, colour = factor(cyl))) +
geom_point()
p2 <- ggplot(mtcars, aes(mpg, wt, colour = factor(cyl))) +
geom_point() +
facet_wrap(~cyl, ncol = 2, scales = "free") +
guides(colour = "none") +
theme()
p3 <- ggplot(mtcars, aes(mpg, wt, colour = factor(cyl))) +
geom_point() +
facet_grid(. ~ cyl, scales = "free")
g1 <- ggplotGrob(p1)
g2 <- ggplotGrob(p2)
g3 <- ggplotGrob(p3)
fg1 <- gtable_frame2(g1)
fg2 <- gtable_frame2(g2)
fg12 <- gtable_frame2(gtable_rbind(fg1, fg2), width = unit(2, "null"),
height = unit(1, "null"))
fg3 <- gtable_frame2(g3, width = unit(1, "null"), height = unit(1, "null"))
grid.newpage()
combined <- gtable_cbind(fg12, fg3)
grid.draw(combined)
Geological timescale axis guide
Description
guide_geo
behaves similarly to ggplot2::guide_axis()
in that it modifies
the visual appearance of the axis. The main difference is that it adds a
geological timescale instead of an axis.
Usage
guide_geo(
dat = "periods",
fill = NULL,
alpha = 1,
height = unit(2, "line"),
bord = c("left", "right", "top", "bottom"),
lwd = 0.25,
color = "black",
lab = TRUE,
lab_color = NULL,
rot = 0,
family = "sans",
fontface = "plain",
size = 5,
skip = c("Quaternary", "Holocene", "Late Pleistocene"),
abbrv = TRUE,
neg = FALSE,
end_labels = "center",
dat_is_discrete = FALSE,
fittext_args = list(),
theme = NULL,
title = waiver(),
order = 0,
position = waiver()
)
Arguments
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 Details). |
fill |
The fill color of the boxes. The default is to use the |
alpha |
The transparency of the fill colors. |
height |
The height (or width if |
bord |
A vector specifying on which sides of the scale to add borders
(same options as |
lwd |
Line width. |
color |
The outline color of the interval boxes. |
lab |
Whether to include labels. |
lab_color |
The color of the labels. The default is to use the
|
rot |
The amount of counter-clockwise rotation to add to the labels (in degrees). |
family |
The font family to use for the labels. There are only three fonts that are guaranteed to work everywhere: “sans” (the default), “serif”, or “mono”. |
fontface |
The font face to use for the labels. The standard options are "plain" (default), "bold", "italic", and "bold.italic". |
size |
Label size. Either a number as you would specify in
|
skip |
A vector of interval names indicating which intervals should not
be labeled. If |
abbrv |
If including labels, should the labels be abbreviated? If
|
neg |
Set this to |
end_labels |
How should labels for intervals at the ends of the guide be treated? "center", the default, centers the labels within the visible part of the label. "clip" removes the labels if their midpoint is beyond the axis limits. "keep" plots the labels in the midpoint of the full interval. |
dat_is_discrete |
Are the ages in |
fittext_args |
A list of named arguments to provide to
|
theme |
A |
title |
A character string or expression indicating a title of guide.
If |
order |
A positive |
position |
Where this guide should be drawn: one of top, bottom, left, or right. |
Details
If a custom data.frame is provided (with dat
), it should consist of at
least 3 columns of data. See data(periods)
for an example.
The
name
column lists the names of each time interval. These will be used as labels if no abbreviations are provided.The
max_age
column lists the oldest boundary of each time interval.The
min_age
column lists the youngest boundary of each time interval.The
abbr
column is optional and lists abbreviations that may be used as labels.The
color
column is also optional and lists a color for the background for each time interval.The
lab_color
column is also optional and lists a color for the label for each time interval.
If the axis of the time scale is discrete, max_age
and min_age
will
automatically be converted to the discrete scale. In this case, the
categories of the discrete axis should match the values in the name
column.
If the ages within dat
are already discretized, you can set
dat_is_discrete
to TRUE
to prevent this automatic conversion. This can be
useful for adding a time scale where categories and time intervals are not
1:1.
Since this guide only plots the timescale and not ticks or an axis line, a
call to this function should almost always be combined with a call to
ggplot2::guide_axis()
within a call to ggplot2::guide_axis_stack()
(see
Examples). Note that in most cases this has the same end result as a single
call to coord_geo()
; however, there are some use cases in which this may be
more useful or allow for more customization. For example, users may wish to
combine this guide in unique ways with other guides. Further, since
coord_geo()
doesn't work with radial/fan phylogenies (and
coord_geo_radial()
is quite different visually), this guide can be used to
achieve the look of coord_geo()
on a radial/fan phylogeny.
Examples
library(ggplot2)
# reproduce the coord_geo() appearance
ggplot() +
geom_point(aes(y = runif(1000, 0, 8), x = runif(1000, 0, 1000))) +
scale_x_reverse(guide = guide_axis_stack(guide_geo(), "axis",
spacing = unit(0, "npc"))) +
coord_cartesian(xlim = c(1000, 0), ylim = c(0, 8)) +
theme_classic()
# the coord_geo() look on a radial phylogeny
library(ggtree)
library(paleotree)
data(RaiaCopesRule)
ggtree(ceratopsianTreeRaia,
position = position_nudge(x = -ceratopsianTreeRaia$root.time)) +
coord_geo_radial(dat = "stages", fill = c("grey80", "grey95"),
end = 1.25 * pi) +
guides(
r = guide_axis_stack(guide_geo(rot = -90, neg = TRUE,
height = unit(0.5, "line")),
"axis", spacing = unit(0, "npc"))
) +
scale_y_continuous(guide = "none", breaks = NULL) +
theme_classic()
Combined wireframe and cloud panel
Description
Plots the provided data on 2-D surfaces within a 3-D framework. See
disparity_through_time()
.
Usage
panel.disparity(x, y, z, groups, subscripts, ...)
Arguments
x , y , z , groups , subscripts , ... |
Same as for |
Value
No return value, plots the results of both lattice::panel.cloud()
and lattice::panel.wireframe()
.
Period data from the International Commission on Stratigraphy (v2024/12)
Description
A dataset containing the boundary ages, abbreviations, and colors for the periods of the Geologic Time Scale. Based on The ICS International Chronostratigraphic Chart (v2024/12), by Cohen, Finney, Gibbard, and Fan.
Usage
periods
Format
A data frame with 22 rows and 5 variables:
- name
period name
- max_age
maximum age, in millions of years
- min_age
minimum age, in millions of years
- abbr
period name abbreviations
- color
the colors for each period, according to the Commission for the Geological Map of the World
- lab_color
the label colors for each period, either white or black, whichever has better contrast with the background color, based on recommendations by the International Telecommunication Union
Source
https://stratigraphy.org via https://macrostrat.org/api/v2/defs/intervals?timescale=international%20periods
See Also
Other built-in timescales:
eons
,
epochs
,
eras
,
stages
Geological Time Scale color scales
Description
Color scales using the colors in the Geological Time Scale graphics.
Usage
scale_color_geo(dat, ...)
scale_fill_geo(dat, ...)
scale_discrete_geo(dat, aesthetics, ...)
Arguments
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 |
Examples
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()
Geologic pattern fill scale
Description
Fill scale using the FGDC Digital Cartographic Standard for Geologic Map Symbolization. Fill values should correspond to specific pattern codes (see "Details").
Usage
scale_fill_geopattern(na.value = "grey50", ...)
Arguments
na.value |
The aesthetic value to use for missing (NA) values. May be
either a color or a GridPattern object (such as that
returned by |
... |
Arguments passed on to
|
Details
For specific codes, see the "pattern numbers" in the full pattern chart
for valid code
values. Daven Quinn has also assembled more accessible
documentation of the map patterns/codes
and lithology patterns/codes.
rmacrostrat::def_lithologies()
can also be used to look up pattern codes
for various lithologies (see the "fill" column). Note that codes associated
with color variants (e.g., "101-M") are supported but will result in the
default color variant instead (usually black and white, e.g., "101-K").
These patterns were originally processed and optimized by Daven Quinn and are hosted on GitHub.
Warning
Pattern fills are not supported on all graphics devices.
Not all devices are under active development, and such devices are unlikely
to add support for new features (such as pattern fills). The new features
have only been implemented on a subset of graphics devices so far:
cairo_pdf()
, cairo_ps()
, x11(type="cairo")
,
png(type="cairo")
,
jpeg(type="cairo")
,
tiff(type="cairo")
, svg()
, and pdf()
. Although
there is no support yet for quartz()
or windows()
, almost all of the
graphics devices above will work on all major platforms. Further, the
ragg and
svglite packages contain graphics
devices that support patterns. When using a graphics device where patterns
are not supported, closed shapes will be rendered with a transparent fill.
Note that, at least on Windows machines, the default device in RStudio and
in the knitr package is png()
, which does not support patterns. In
RStudio, you can go to ‘Tools > Global Options > General > Graphics’ and
choose the ‘Cairo PNG’ device from the dropdown menu to display patterns.
Similar issues may arise when using RStudio on other operating systems.
See Also
FGDC patterns:
geo_pattern()
,
grid.pattern_geo()
Examples
library(ggplot2)
vals <- c("101", "313", "603", "733")
ggplot(mpg, aes(factor(cyl), fill = vals[factor(cyl)])) +
geom_bar() +
scale_fill_geopattern(name = NULL)
Stage data from the International Commission on Stratigraphy (v2024/12)
Description
A dataset containing the boundary ages, abbreviations, and colors for the stages of the Geologic Time Scale. Based on The ICS International Chronostratigraphic Chart (v2024/12), by Cohen, Finney, Gibbard, and Fan.
Usage
stages
Format
A data frame with 102 rows and 5 variables:
- name
stage name
- max_age
maximum age, in millions of years
- min_age
minimum age, in millions of years
- abbr
stage name abbreviations
- color
the colors for each stage, according to the Commission for the Geological Map of the World
- lab_color
the label colors for each stage, either white or black, whichever has better contrast with the background color, based on recommendations by the International Telecommunication Union
Source
https://stratigraphy.org via https://macrostrat.org/api/v2/defs/intervals?timescale=international%20ages