Description Usage Arguments Format Details Value Examples
View source: R/geom-timeline-label.R
Labels for timeline geom for earthquake data
1 2 3 4 5 | geom_timeline_label(mapping = NULL, data = NULL, stat = "identity",
position = "identity", ..., na.rm = FALSE, show.legend = NA,
inherit.aes = TRUE)
GeomTimelineLabel
|
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
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. |
... |
other arguments passed on to |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
An object of class GeomTimelineLabel
(inherits from Geom
, ggproto
) of length 5.
TThis geom adds a vertical line to each data point with a text annotation (e.g. the location of the earthquake) attached to each line. Aesthetics are x, which is the date of the earthquake and label which takes the column name from which annotations will be obtained.
Returns the geom for ggplot2 graphics
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | library(dplyr)
library(ggplot2)
library(lubridate)
data <- earthquake_data %>%
filter(COUNTRY %in% c('USA', 'CHINA'))
labels <- data %>%
top_earthquakes(10, ymd('2000-01-01'), ymd('2015-12-31'))
ggplot(data, aes(x = DATE, y = COUNTRY, fill = DEATHS)) +
geom_timeline(aes(size = EQ_PRIMARY), alpha = 0.25,
xmin = ymd('2000-01-01'), xmax = ymd('2015-12-31')) +
geom_timeline_label(data = labels,
mapping = aes(x = DATE, y = COUNTRY, label = LOCATION_NAME))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.