geom_points_range {deeptime} | R Documentation |
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, either as a |
position |
Position adjustment, either as a string naming the adjustment
(e.g. |
... |
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, either as 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()