geom_timeline: GeomTimeline: 'geom_timeline()'

Description Usage Arguments Value Examples

Description

This geom and geom_timeline function will plot a time line of earthquakes ranging from xmin to xmax dates with a point for each earthquake. Optional aesthetics include color, size, and alpha (for transparency). The x aesthetic is a date and an optional y aesthetic is a factor indicating some stratification in which case multiple time lines will be plotted for each level of the factor (e.g. country).

Usage

1
2
3
geom_timeline(mapping = NULL, data = NULL, stat = "timeline",
  position = "identity", na.rm = FALSE, show.legend = NA,
  inherit.aes = TRUE, xmin = NULL, xmax = 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.

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

A Date class date which specifies the minimum timeline range. This is optional. If not specified, The minimum timeline range of the data is assumed.

xmax

A Date class date which specifies the maximum timeline range. This is optional. If not specified, The maximum timeline range of the data is assumed.

...

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

plot of a time line of earthquakes ranging from xmin to xmax dates with a point for each earthquake.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
## Not run: 
library(dplyr)
library(lubridate)
data(raw_df)
test_df <- raw_df %>% eq_clean_data() %>%
filter(COUNTRY == "TURKEY" | COUNTRY == "JAPAN") %>%
dplyr::filter(DATE >= eq_date("2000-01-01") & DATE <= eq_date("2017-01-01"))

## End(Not run)

## Not run: 
ggtimeline <- ggplot2::ggplot(test_df) +
geom_timeline(ggplot2::aes(
                           x = DATE,
                           y = COUNTRY,
                           size = EQ_PRIMARY,
                           fill = TOTAL_DEATHS)
                           ) +
eq_theme +
ggplot2::scale_size_continuous(name = "Richer scale value", breaks = c(0, 2, 4, 6, 8)) +
ggplot2::scale_fill_continuous(name = "# deaths") +
ggplot2::ggtitle("Earthquakes")

ggtimeline

## End(Not run)

atibot/eqplot documentation built on May 17, 2019, 4 p.m.