geom_timeline_label: Display timeline labels

Description Usage Arguments Value Examples

Description

The geom_timeline_label function displays timeline labels based on the GeomTimelineLabel. It is usually used together with the geom_timeline function.

Usage

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

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. If NULL, the default, the data is 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, 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.

inherit.aes

If FALSE, overrides the default aesthetics, rather than combining with them.

...

other arguments passed on to layer. These are often aesthetics, used to set an aesthetic to a fixed value.

Value

Timeline labels are added to a timeline plot.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# stratification and text annotations as in figure 3 of module 2
file <- system.file("extdata", "earthquakes.tsv.gz", package = "NOAAeq")
library(magrittr)
readr::read_delim(file = file, delim = "\t") %>%
  eq_clean_data() %>%
  dplyr::filter(lubridate::year(DATE) %in% 2000:2017 & COUNTRY %in% c("USA", "CHINA")) %>%
  ggplot(aes(x = DATE, y = COUNTRY, fill = TOTAL_DEATHS)) +
  geom_timeline() +
  geom_timeline_label(aes(label = LOCATION_NAME, col_max = EQ_PRIMARY), n_max = 5) +
  theme_classic() +
  theme(legend.position = "bottom",
        axis.title.y = element_blank(), axis.ticks.y = element_blank(),
        axis.line.y = element_blank()) +
  scale_fill_continuous(name = "# deaths", breaks = c(1, 87652))

la-sch/NOAAeq documentation built on May 20, 2019, 7:31 p.m.