Description Usage Format Value Aesthetics Examples
GeomTimeline
constructs a new class for a timeline geom plotting one
or multiple timelines of earthquakes.
1 |
An object of class GeomTimeline
(inherits from Geom
, ggproto
) of length 5.
A new ggproto object for a timeline geom.
x
: The column of the given data frame depicting the x values of the
timeline geom, usually date.
y
: Optional. The column of the given data frame depicting the y
values of the timeline geom, usually location.
size
: Optional. The column of the given data frame depicting the size
of each point in the timeline geom.
colour
: Optional. The column of the given data frame depicting the
color of each point in the timeline geom.
fill
: Optional. A color string depicting the default fill of each
point in the timeline geom.
shape
: Optional. The column of the given data frame depicting the
shape of each point in the timeline geom.
alpha
: Optional. The column of the given data frame depicting the
alpha value of each point in the timeline geom.
stroke
: Optional. The stroke of the timeline geom.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | # import libraries
library(dplyr)
library(readr)
# set working directory
setwd(system.file("extdata", package = "noaa"))
# read and clean NOAA data
data <- read_delim("signif.txt", "\t") %>%
eq_clean_data() %>%
dplyr::filter(COUNTRY %in% c("USA", "CHINA"), YEAR > 2000)
# plot NOAA data
ggplot2::ggplot(data, ggplot2::aes(DATE,
colour = as.numeric(TOTAL_DEATHS),
y = COUNTRY,
size = as.numeric(EQ_PRIMARY))) +
geom_timeline() +
ggplot2::guides(size = ggplot2::guide_legend(title = "Richter Scale")) +
ggplot2::scale_colour_continuous(name = "Number of Deaths") +
ggplot2::theme_classic()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.