Description Usage Arguments Format Details Value Examples
View source: R/geom_timeline_label.R
Labels for timeline geom for earthquake data from NOAA
1 2 3 4 5 6 7 8 9 10 11 12 | GeomTimelineLabel
geom_timeline_label(
mapping = NULL,
data = NULL,
stat = "identity",
position = "identity",
...,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
|
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. Cannot be jointy specified with
|
... |
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
, gg
) of length 5.
This geom adds a label to each data point that consists of a line and a text (for instance, the location of the earthquake) attached to each line. The x aesthetic provides the date vector for the timeline and label provides the labelling vector.
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 <- eq_clean_data(raw_noaa) %>%
filter(COUNTRY %in% c('USA', 'CHINA'))
labels <- data %>%
top_eq(n_max = 10, min_date = ymd('2000-01-01'), max_date = 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.