geom_timeline_label: Add Timeline Label

Description Usage Arguments Details Aesthetics Examples

View source: R/eq_geoms.R

Description

geom_timeline_label adds labels to a timeline generated by geom_timeline for a specified number of ranked events. It draws vertical lines above points on the timeline and adds a label for each event.

Usage

1
2
3
geom_timeline_label(mapping = NULL, data = NULL, na.rm = TRUE,
  show.legend = NA, stat = "identity", position = "identity",
  inherit.aes = TRUE, n_max = NULL, ...)

Arguments

mapping

Set of aesthetic mappings created by aes() or aes_(). If specified and inherit.aes = TRUE (the default), it is combined with the default mapping at the top level of the plot. You must supply mapping if there is no plot mapping.

data

The data to be displayed in this layer. There are three options:

If NULL, the default, the data is inherited from the plot data as specified in the call to ggplot().

A data.frame, or other object, will override the plot data. All objects will be fortified to produce a data frame. See fortify() for which variables will be created.

A function will be called with a single argument, the plot data. The return value must be a data.frame, and will be used as the layer data.

na.rm

If FALSE, the default, missing values are removed with a warning. If TRUE, missing values are silently removed.

show.legend

logical. Should this layer be included in the legends? NA, the default, includes if any aesthetics are mapped. FALSE never includes, and TRUE always includes. It can also be a named logical vector to finely select the aesthetics to display.

stat

The statistical transformation to use on the data for this layer, as a string.

position

Position adjustment, either as a string, or the result of a call to a position adjustment function.

inherit.aes

If FALSE, overrides the default aesthetics, rather than combining with them. This is most useful for helper functions that define both data and aesthetics and shouldn't inherit behaviour from the default plot specification, e.g. borders().

n_max

The top n_max labels to plot as an integer, e.g. if you want to label the top five earthquakes by magnitude, pass 5 to this parameter.

...

Other arguments passed on to layer(). These are often aesthetics, used to set an aesthetic to a fixed value, like colour = "red" or size = 3. They may also be parameters to the paired geom/stat.

Details

geom_timeline_label provides one option to label the n_max events sorted by a selected variable.

Aesthetics

geom_timeline_label understands the following aesthetics (required are in bold):

Examples

1
2
3
4
5
6
7
8
9
## Not run: 
ggplot(data = earthquakes, aes(x = DATE, y = COUNTRY)) +
    geom_timeline(xmin = "2000-01-01", xmax = "2018-12-31",
                  aes(color = TOTAL_DEATHS, size = EQ_PRIMARY)) +
    geom_timeline_label(n_max = 5,
                        aes(label = LOCATION_NAME,
                                    magnitude = EQ_PRIMARY))

## End(Not run)

dtminnick/earthquake documentation built on Nov. 4, 2019, 11:04 a.m.