geom_timeline_label: geom_timeline_label ggplot2 geometry

Description Usage Arguments Value Examples

View source: R/plot.R

Description

This function create an ad hoc geometry to visualize a label for the timeline of earthquakes. The geometry is represented by a vertical line and a text label. The max number of labels is controlled by the parameter n_max.

Usage

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

Arguments

mapping

Set of aesthetic mappings created by aes or aes_.

data

The data to be displayed in this layer.

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.

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.

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.

xmin

minimum date to be displayed

xmax

maximum date to be displayed

n_max

Max number of labels to display per each row. Default = 5.

fill

Color to use for filling.

...

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

Value

a ggplot2 geometry

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## Not run: 
data %>%
  dplyr::filter(COUNTRY == "USA" & YEAR > 2000) %>%
  ggplot() +
    geom_timeline(aes(x = DATE, y = COUNTRY, size = EQ_PRIMARY, color = DEATHS)) +
    geom_timeline_label(aes(x = DATE, y = COUNTRY, label = LOCATION_NAME,
      size = EQ_PRIMARY), n_max = 5) +
    labs(size = "Richter Scale value:", color = "# of Deaths:")

## End(Not run)

frenkg/courseraeq documentation built on May 22, 2019, 12:42 p.m.