Title: | 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. |
Authors: | William Gearty [aut, cre] |
Maintainer: | William Gearty <[email protected]> |
License: | GPL (>= 3) |
Version: | 2.1.0.9000 |
Built: | 2024-11-01 15:18:03 UTC |
Source: | https://github.com/willgearty/deeptime |
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.
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() )
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() )
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
|
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).
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()
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()
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.
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() )
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() )
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
|
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 = NA)
. 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.
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.
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")
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")
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).
coord_geo_radial( dat = "periods", theta = "y", start = -0.5 * pi, end = 1.25 * pi, expand = TRUE, direction = 1, 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 )
coord_geo_radial( dat = "periods", theta = "y", start = -0.5 * pi, end = 1.25 * pi, expand = TRUE, direction = 1, 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 )
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 |
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 |
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.
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()
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()
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()
.
coord_trans_flip( x = "identity", y = "identity", xlim = NULL, ylim = NULL, clip = "on", expand = TRUE )
coord_trans_flip( x = "identity", y = "identity", xlim = NULL, ylim = NULL, clip = "on", expand = TRUE )
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 |
library(ggplot2) ggplot(mtcars, aes(disp, wt)) + geom_point() + coord_trans_flip(x = "log10", y = "log10")
library(ggplot2) ggplot(mtcars, aes(disp, wt)) + geom_point() + coord_trans_flip(x = "log10", y = "log10")
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
.
coord_trans_xy( trans = NULL, xlim = NULL, ylim = NULL, expand = FALSE, default = FALSE, clip = "on" )
coord_trans_xy( trans = NULL, xlim = NULL, ylim = NULL, expand = FALSE, default = FALSE, clip = "on" )
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 |
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.
# 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()
# 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()
Plots points on 2-D surfaces within a a 3-D framework. See
lattice::wireframe()
and lattice::panel.cloud()
for customization
options.
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)), ... )
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)), ... )
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 |
An object of class "trellis"
, as output by lattice::wireframe()
.
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") )
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") )
A dataset containing the boundary ages, abbreviations, and colors for the eons of the Geologic Time Scale. Based on The ICS International Chronostratigraphic Chart (v2023/06), by Cohen, Finney, Gibbard, and Fan.
eons
eons
A data frame with 3 rows and 5 variables:
eon name
maximum age, in millions of years
minimum age, in millions of years
eon name abbreviations
the colors for each eon, according to the Commission for the Geological Map of the World
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
https://stratigraphy.org via https://macrostrat.org/api/v2/defs/intervals?timescale=international%20eons
Other built-in timescales:
epochs
,
eras
,
periods
,
stages
A dataset containing the boundary ages, abbreviations, and colors for the epochs of the Geologic Time Scale. Based on The ICS International Chronostratigraphic Chart (v2023/06), by Cohen, Finney, Gibbard, and Fan.
epochs
epochs
A data frame with 34 rows and 5 variables:
epoch name
maximum age, in millions of years
minimum age, in millions of years
epoch name abbreviations
the colors for each epoch, according to the Commission for the Geological Map of the World
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
https://stratigraphy.org via https://macrostrat.org/api/v2/defs/intervals?timescale=international%20epochs
Other built-in timescales:
eons
,
eras
,
periods
,
stages
A dataset containing the boundary ages, abbreviations, and colors for the eras of the Geologic Time Scale. Based on The ICS International Chronostratigraphic Chart (v2023/06), by Cohen, Finney, Gibbard, and Fan.
eras
eras
A data frame with 10 rows and 5 variables:
era name
maximum age, in millions of years
minimum age, in millions of years
era name abbreviations
the colors for each era, according to the Commission for the Geological Map of the World
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
https://stratigraphy.org via https://macrostrat.org/api/v2/defs/intervals?timescale=international%20eras
Other built-in timescales:
eons
,
epochs
,
periods
,
stages
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()
.
facet_grid_color( rows = NULL, cols = NULL, scales = "fixed", space = "fixed", shrink = TRUE, labeller = "label_value", colors = stages, lab_colors = "auto", as.table = TRUE, switch = NULL, drop = TRUE, margins = FALSE, axes = "margins", axis.labels = "all" )
facet_grid_color( rows = NULL, cols = NULL, scales = "fixed", space = "fixed", shrink = TRUE, labeller = "label_value", colors = stages, lab_colors = "auto", as.table = TRUE, switch = NULL, drop = TRUE, margins = FALSE, axes = "margins", axis.labels = "all" )
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 |
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 |
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 |
Other faceting functions:
facet_nested_color()
,
facet_nested_wrap_color()
,
facet_wrap_color()
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)
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)
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.
facet_nested_color( rows = NULL, cols = NULL, scales = "fixed", space = "fixed", axes = "margins", remove_labels = "none", independent = "none", shrink = TRUE, labeller = "label_value", colors = stages, 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_color( rows = NULL, cols = NULL, scales = "fixed", space = "fixed", axes = "margins", remove_labels = "none", independent = "none", shrink = TRUE, labeller = "label_value", colors = stages, 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 )
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 |
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 |
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 |
the |
This function inherits the capabilities of
facet_grid2()
.
Unlike facet_grid()
, this function only automatically expands
missing variables when they have no variables in that direction, to allow
for unnested variables. It still requires at least one layer to have all
faceting variables.
Hierarchies are inferred from the order of variables supplied to
rows
or cols
. The first variable is interpreted to be the
outermost variable, while the last variable is interpreted to be the
innermost variable. They display order is always such that the outermost
variable is placed the furthest away from the panels. For more information
about the nesting of strips, please visit the documentation of
strip_nested()
.
Other faceting functions:
facet_grid_color()
,
facet_nested_wrap_color()
,
facet_wrap_color()
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))
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))
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.
facet_nested_wrap_color( facets, nrow = NULL, ncol = NULL, scales = "fixed", axes = "margins", remove_labels = "none", shrink = TRUE, labeller = "label_value", colors = stages, 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_color( facets, nrow = NULL, ncol = NULL, scales = "fixed", axes = "margins", remove_labels = "none", shrink = TRUE, labeller = "label_value", colors = stages, 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 )
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, |
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 |
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 |
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 |
the |
This function inherits the capabilities of
facet_wrap2()
.
This function only merges strips in the same row or column as they appear
through regular facet_wrap()
layout behaviour.
Hierarchies are inferred from the order of variables supplied to
facets
. The first variable is interpreted to be the outermost
variable, while the last variable is interpreted to be the innermost
variable. They display order is always such that the outermost
variable is placed the furthest away from the panels. For more information
about the nesting of strips, please visit the documentation of
strip_nested()
.
Other faceting functions:
facet_grid_color()
,
facet_nested_color()
,
facet_wrap_color()
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))
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))
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.
facet_wrap_color( facets, nrow = NULL, ncol = NULL, scales = "fixed", shrink = TRUE, labeller = "label_value", colors = stages, lab_colors = "auto", as.table = TRUE, drop = TRUE, dir = "h", strip.position = "top", axes = "margins", axis.labels = "all" )
facet_wrap_color( facets, nrow = NULL, ncol = NULL, scales = "fixed", shrink = TRUE, labeller = "label_value", colors = stages, lab_colors = "auto", as.table = TRUE, drop = TRUE, dir = "h", strip.position = "top", axes = "margins", axis.labels = "all" )
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, |
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 |
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 |
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 |
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 |
Other faceting functions:
facet_grid_color()
,
facet_nested_color()
,
facet_nested_wrap_color()
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)
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)
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).
geo_pattern( code, scale = 2, col = NULL, fill = NULL, alpha = NULL, bg = "white" ) geo_grob(code, col = NULL, fill = NULL, alpha = NULL, bg = "white")
geo_pattern( code, scale = 2, col = NULL, fill = NULL, alpha = NULL, bg = "white" ) geo_grob(code, col = NULL, fill = NULL, alpha = NULL, bg = "white")
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. |
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.
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.
FGDC patterns:
grid.pattern_geo()
,
scale_fill_geopattern()
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)))
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)))
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.
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 )
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 )
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 |
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).
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)
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)
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.
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 )
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 )
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
|
geom_points_range()
understands the following
aesthetics (required aesthetics are in bold):
x
y
size
color/colour
fill
shape
alpha
group
linetype
linewidth
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)
or after_stat(xmin)
the minimum extent of the point range
after_stat(ymax)
or after_stat(xmax)
the maximum extent of the point range
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.
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()
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()
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.
get_scale_data(name, true_colors = TRUE)
get_scale_data(name, true_colors = TRUE)
name |
The name of the desired timescale. |
true_colors |
Return original international time scale colors? (as opposed to custom Macrostrat plotting colors) |
The following timescales are available from the Macrostrat API as of 2024-10-24:
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.
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 |
Arrange multiple ggplot, grobified ggplot, or geo_scale objects on a page, aligning the plot panels, axes, and axis titles.
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)) )
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)) )
... |
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 |
gtable of aligned plots
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)
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)
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).
grid.pattern_geo(params, boundary_df, aspect_ratio, legend = FALSE)
grid.pattern_geo(params, boundary_df, aspect_ratio, legend = FALSE)
params |
A list of pattern parameters to customize the plotted pattern (see "Details"). |
boundary_df |
A |
aspect_ratio |
Unused. |
legend |
Unused. |
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"
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.
FGDC patterns:
geo_pattern()
,
scale_fill_geopattern()
# 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'))
# 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'))
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.
gtable_frame2( g, width = unit(1, "null"), height = unit(1, "null"), debug = FALSE )
gtable_frame2( g, width = unit(1, "null"), height = unit(1, "null"), debug = FALSE )
g |
gtable |
width |
requested width |
height |
requested height |
debug |
logical draw gtable cells |
7x7 gtable wrapping the plot
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)
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)
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.
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() )
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() )
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. |
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.
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()
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()
Plots the provided data on 2-D surfaces within a 3-D framework. See
disparity_through_time()
.
panel.disparity(x, y, z, groups, subscripts, ...)
panel.disparity(x, y, z, groups, subscripts, ...)
x , y , z , groups , subscripts , ...
|
Same as for |
No return value, plots the results of both lattice::panel.cloud()
and lattice::panel.wireframe()
.
A dataset containing the boundary ages, abbreviations, and colors for the periods of the Geologic Time Scale. Based on The ICS International Chronostratigraphic Chart (v2023/06), by Cohen, Finney, Gibbard, and Fan.
periods
periods
A data frame with 22 rows and 5 variables:
period name
maximum age, in millions of years
minimum age, in millions of years
period name abbreviations
the colors for each period, according to the Commission for the Geological Map of the World
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
https://stratigraphy.org via https://macrostrat.org/api/v2/defs/intervals?timescale=international%20periods
Other built-in timescales:
eons
,
epochs
,
eras
,
stages
Color scales using the colors in the Geological Time Scale graphics.
scale_color_geo(dat, ...) scale_fill_geo(dat, ...) scale_discrete_geo(dat, aesthetics, ...)
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()
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()
Fill scale using the FGDC Digital Cartographic Standard for Geologic Map Symbolization. Fill values should correspond to specific pattern codes (see "Details").
scale_fill_geopattern(na.value = "grey50", ...)
scale_fill_geopattern(na.value = "grey50", ...)
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
|
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.
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.
FGDC patterns:
geo_pattern()
,
grid.pattern_geo()
library(ggplot2) vals <- c("101", "313", "603", "733") ggplot(mpg, aes(factor(cyl), fill = vals[factor(cyl)])) + geom_bar() + scale_fill_geopattern(name = NULL)
library(ggplot2) vals <- c("101", "313", "603", "733") ggplot(mpg, aes(factor(cyl), fill = vals[factor(cyl)])) + geom_bar() + scale_fill_geopattern(name = NULL)
A dataset containing the boundary ages, abbreviations, and colors for the stages of the Geologic Time Scale. Based on The ICS International Chronostratigraphic Chart (v2023/06), by Cohen, Finney, Gibbard, and Fan.
stages
stages
A data frame with 102 rows and 5 variables:
stage name
maximum age, in millions of years
minimum age, in millions of years
stage name abbreviations
the colors for each stage, according to the Commission for the Geological Map of the World
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
https://stratigraphy.org via https://macrostrat.org/api/v2/defs/intervals?timescale=international%20ages
Other built-in timescales:
eons
,
epochs
,
eras
,
periods