Chapter 4 GeomTimeline
This function acts behind the scenes creating all the visuals to be displayed by the geom_timeline
.
Although this function is wrapped by the geom_timeline
you can still use it by the use of ggplot2::layer
.
4.1 Example
Using ggplot2::layer
to plot the visuals of GeomTimeline
.
# Path to the raw data.
raw_data_path <- system.file("extdata", "signif.txt", package = "msdr")
# Loading the dataset of Earthquake.
df <- readr::read_delim(file = raw_data_path,
delim = '\t',
col_names = TRUE,
progress = FALSE,
col_types = readr::cols())
# Cleaning and Creating LOCATION column.
df_clean <- df %>% eq_clean_data() %>% filter(COUNTRY %in% c('CANADA','USA','MEXICO'))
# Plotting using layer.
ggplot2::ggplot() +
ggplot2::layer(geom = GeomTimeline,
mapping = aes(x = DATE,
y = COUNTRY,
size = EQ_PRIMARY,
color = TOTAL_DEATHS),
data = df_clean,
stat = 'identity',
position = 'identity',
show.legend = NA,
inherit.aes = TRUE,
params = list(na.rm = FALSE)) + theme_msdr()