View source: R/coord_geo_radial.R
coord_geo_radial | R Documentation |
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
)
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()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.