Description Usage Arguments Aesthetics Examples
View source: R/geom-timeline.R
This geom is used to create timelines for the NOAA Significant Earthquakes dataset.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | geom_timeline_label(
mapping = NULL,
data = NULL,
position = "identity",
show.legend = NA,
na.rm = FALSE,
inherit.aes = TRUE,
...
)
geom_timeline(
mapping = NULL,
data = NULL,
position = "identity",
show.legend = NA,
na.rm = FALSE,
inherit.aes = TRUE,
...
)
stat_timeline_label(
mapping = NULL,
data = NULL,
geom = "timeline_label",
position = "identity",
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE,
...
)
stat_timeline(
mapping = NULL,
data = NULL,
geom = "timeline",
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 |
position |
Position adjustment, either as a string, or the result of a call to a position adjustment function. |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
geom |
The geometric object to use display the data |
geom_timeline()
understands the following aesthetics (required aesthetics are in bold):
x
min_date
max_date
color
size
alpha
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | ## Not run:
library(msdrCourseraCapstonePackage)
library(magrittr)
library(ggplot2)
library(dplyr)
library(lubridate)
data_path <- system.file("extdata", "signif.txt", package = "msdrCourseraCapstonePackage")
eq_data_raw <- read.delim(data_path)
eq_data <- eq_clean_data(eq_data_raw)
eq_data_plot <- eq_data %>% filter(COUNTRY %in% c("CANADA", "USA", "MEXICO"))
# basic timeline of entire dataset
ggplot(eq_data_plot, aes(x = DATE)) + geom_timeline() + theme_eq
# filter timeline with a min date
ggplot(eq_data_plot, aes(x = DATE, min_date = as.Date("1900-01-01"))) + geom_timeline() + theme_eq
# add a max date as well
ggplot(eq_data_plot, aes(x = DATE, min_date = as.Date("1900-01-01"), max_date = as.Date("1950-01-01"))) + geom_timeline() + theme_eq
# use y aesthetic to add COUNTRY stratification
ggplot(eq_data_plot, aes(x = DATE, y = COUNTRY, min_date = as.Date("1900-01-01"), max_date = as.Date("1950-01-01"))) + geom_timeline() + theme_eq
# use size and color of points to represent magnitude and number of casualties, and set alpha to 0.3
plot <- ggplot(eq_data_plot, aes(x = DATE, y = COUNTRY, min_date = as.Date("1900-01-01"), max_date = as.Date("1950-01-01"), size = EQ_PRIMARY, color = TOTAL_DEATHS)) + geom_timeline(alpha = 0.3) + theme_eq
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.