geom_timeline_label: Create a timeline label geom

Description Usage Arguments Value Note Examples

Description

This function adds a geom which displays labels for points on a timeline for NOAA earthquake data. This is the basic label visualization without additional modifications. For a cleaner visualization the wrapper function, eq_time, should be used.

Usage

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

Arguments

mapping

A set of aesthetic mappings. If null, uses the default setting in ggplot()

data

A dataset If null, uses the default data specified in ggplot()

stat

The name of the statistical transformation to use. Identity means keep the data as is.

position

The method used to adjust overlapping objects. Identity means keep the position as is.

na.rm

Flag to remove values with NA

show.legend

Flag to say whether layer should be present in legend.

inherit.aes

Flag to say whether default aesthetics should be inherited.

n_max

The number of earthquakes to be labeled. The earthquakes with n_max highest magnitudes will be labeled.

...

Additional arguments passed to layer()

Value

This function returns a layer that can be added to a plot using the ggplot function

Note

The parameters for GeomTimeLineLabel include columns from the earthquake data: Required parameters: x=DATE, label=LOCATION_NAME Optional parameters: n_max=x where x is the number of earthquakes with the highest magnitude to label.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
## Not run: 
sample_USA <- readr::read_delim(filename, delim = "\t") %>%
eq_clean_data() %>%
dplyr::filter(COUNTRY == "USA" & lubridate::year(DATE) >= 2000)

ggplot(data = sample_USA, aes(x=DATE)) + geom_timeline() +
geom_timeline_label(data=sample_USA,aes(label=LOCATION_NAME),n_max=5) + theme_classic()

ggplot() +
geom_timeline_label(data=sample_USA,aes(x=DATE,label=LOCATION_NAME))

sample_2_countries<- readr::read_delim(filename, delim = "\t") %>%
eq_clean_data() %>%
dplyr::filter((COUNTRY=="USA" | COUNTRY=="CHINA") & lubridate::year(DATE) >= 2000)

ggplot() +
geom_timeline_label(data=sample_2_countries,aes(x=DATE,y=COUNTRY,label=LOCATION_NAME))

## End(Not run)

leigitcode/earthquakesViz documentation built on May 7, 2019, 11:14 a.m.