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