geom_timelinelabel: Visualize the times at which earthquakes occur within certain...

Description Usage Arguments Details Value Examples

Description

This geom adds a vertical line to each data point with a text annotation (e.g. the location of the earthquake) attached to each line. There is also an option to subset to n_max number of earthquakes, where we take the n_max largest (by magnitude) earthquakes.

Usage

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

Arguments

mapping

Set of aesthetic mappings created.

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?

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, like 'colour = "red"' or 'size = 3'. They may also be parameters to the paired geom/stat.

#' @section Aesthetics: geom_timeline_label understands the following aesthetics (properties of the plot that can show certain elements of the data) (required aesthetics are in bold):

  • x #Time variable

  • label #Factor for adding annotations to the earthquake data

  • y #Factor indicating some stratification

  • n_max #number of earthquakes to subset according to their magnitude (EQ_PRIMARY)

  • y_length #vertical line length to each data point

Details

The data to be used with this geom must be downloaded and readed from NOAA site, https://www.ngdc.noaa.gov/nndc/struts/form?t=101650&s=1&d=1.

Value

The geom geom_timeline_label used with the ggplot function and the geom_timeline geom, add annotations to the n_max largest (by magnitude) earthquakes.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
# The data must be cleaned using the function \code{eq_clean_data}, included in the package.
# The LOCATION_NAME colomn of the data must be cleaned using the function \code{eq_location_clean},
# included in the package.
# Aesthetics can be specified in the \code{ggplot} function or in \code{geom_timeline} geom function
## Not run: 
data <- readr::read_delim("signif.txt", delim = "\t")
data <- eq_clean_data(data)
data <- eq_location_clean(data)
data %>%
dplyr::filter(COUNTRY == c("MEXICO","USA") & lubridate::year(DATE) >= 2010) %>%
ggplot(aes(x=DATE,y=COUNTRY,color=TOTAL_DEATHS,size=EQ_PRIMARY)) +
geom_timeline(alpha=.5) +
geom_timelinelabel(aes(label=LOCATION_NAME),n_max=3) +
theme(legend.position="bottom", legend.box="horizontal", plot.title=element_text(hjust=0.5)) +
ggtitle("Earthquakes Visualization Tool") +
labs(size = "Richter scale value", color = "# deaths")

## End(Not run)

llangevin/EQVT documentation built on May 13, 2019, 5:24 p.m.