geom_timeline: Display timelines

Description Usage Arguments Value Note Examples

Description

The geom_timeline function displays timelines of earthquakes based on the GeomTimeline.

Usage

1
2
3
geom_timeline(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

A timeline plot with one point symbol for each date.

Note

The function only returns reasonable results for CE (Common Era) dates, because the lubridate package cannot handle BCE (Before Common Era) dates, yet.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# size and colour as figure 1 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 == "USA") %>%
  ggplot(aes(x = DATE, size = EQ_PRIMARY, fill = TOTAL_DEATHS)) +
  geom_timeline() +
  theme_classic() +
  theme(legend.position = "bottom") +
  scale_size_continuous(name = "Richter scale value") +
  scale_fill_continuous(name = "# deaths") +
  guides(size = guide_legend(order = 1),
         fill = guide_colourbar(order = 2))

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