geom_timeline_label: Make time line labels

Description Usage Arguments Examples

View source: R/Module2_functions.R

Description

This function adds annotations to the timeline plot. There is an option to subset to n_max to select the number of annotated earthquakes ordered by magnitude.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
geom_timeline_label(
  mapping = NULL,
  data = NULL,
  stat = "identity",
  position = "identity",
  ...,
  nudge_x = 0,
  nudge_y = 0,
  na.rm = FALSE,
  show.legend = NA,
  inherit.aes = TRUE,
  n_max
)

Arguments

mapping

List of aesthetic created by aes() to use for plot.

data

The data to be displayed in this layer. NULL, the default, is the data inherited from the plot data as specified in the call to ggplot().

stat

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

position

Position adjustment.

...

Other arguments passed on to layer.

nudge_x

Horizontal adjustment to nudge labels by.

nudge_y

Vertical adjustment to nudge labels by.

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.

inherit.aes

Will aesthethics be inherited (TRUE/FALSE). If FALSE, overrides the default aesthetics, rather than combining with them.

n_max

Number of labels, ordered by magnitude. Default is 5.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## Not run: 
readr::read_delim("signif.txt", delim = "\t") %>%
 eq_clean_data() %>%
 dplyr::filter((COUNTRY == "USA" | COUNTRY == "CHINA") & (lubridate::year(DATE) >= 2000 &
                                                            lubridate::year(DATE) <= 2015)) %>%
 ggplot() +
 geom_timeline( aes(x = DATE, y = COUNTRY, size = EQ_PRIMARY, fill = DEATHS)) +
 geom_timeline_label( aes(x = DATE, y = COUNTRY, label = LOCATION_NAME,
 n_max = 1, size = EQ_PRIMARY)) +
 theme_eq

## End(Not run)

piavat/eqPlotc5 documentation built on Feb. 20, 2021, 12:15 a.m.