Description Usage Arguments Aesthetics Examples
View source: R/geom_timeline_label.R
geom_timeline_label
works best when used with
geom_timeline
, labeling the top n
earthquakes, by
magnitude, with a specified label field. By default, the labels are for
the top 5 earthquakes for each country specified, however, the user may
adjust this with the n_max
aesthetic.
1 2 3 |
mapping |
See |
data |
See |
stat |
See |
position |
See |
na.rm |
See |
show.legend |
See |
inherit.aes |
See |
... |
other arguments passed on to |
geom_timeline_label
undertands the following aesthetics (required
aesthetics are in bold):
x: recommend DATE
label: recommend LOCATION_NAME
magnitude: recommend EQ_PRIMARY
y: recommend COUNTRY
n_max: default 5. Top n
earthquakes to label,
sorted by magnitude.
color
linetype
size
alpha
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | library(dplyr); library(ggplot2)
quakes <- eq_load_clean_data()
quakes %>%
dplyr::filter(COUNTRY %in% c('USA', 'UK')) %>%
dplyr::filter(DATE > '2000-01-01') %>%
ggplot() +
geom_timeline(aes(x = DATE, y = COUNTRY, color = TOTAL_DEATHS,
size = EQ_PRIMARY)) +
geom_timeline_label(aes(x = DATE, y = COUNTRY, magnitude = EQ_PRIMARY,
label = LOCATION_NAME, n_max = 5)) +
scale_size_continuous(name = 'Richter scale value') +
scale_color_continuous(name = '# of Deaths') +
theme_eq()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.