Description Usage Format Value Aesthetics Examples
GeomTimelineLabel
constructs a new class for a timeline label geom
adding labels to one or many timelines of earthquakes.
1 |
An object of class GeomTimelineLabel
(inherits from Geom
, ggproto
) of length 6.
A new ggproto object for a timeline label geom.
x
: Column of the given data frame depicting the x value to which the
labels will be added, usually date.
label
: Column of the given data frame depicting the label which will
be added.
size
: Column of the given data frame depicting to which points of
the timeline labels will be added.
y
: Optional. Column of the given data frame depicting the y value of
the timelines, usually location.
nmax
: Optional. Numeric for the maximum number of labels.
colour
: Optional. Color string for the colour of the vertical line of
labels.
alpha
: Optional. Numeric for the alpha level applied to the vertical
line of the labels.
stroke
: Optional. Stroke of the image.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | # 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() +
geom_timeline_label(ggplot2::aes(label = data$LOCATION_NAME)) +
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.