GeomTimelineLabel: Construct new Class for Timeline Label Geom

Description Usage Format Value Aesthetics Examples

Description

GeomTimelineLabel constructs a new class for a timeline label geom adding labels to one or many timelines of earthquakes.

Usage

1

Format

An object of class GeomTimelineLabel (inherits from Geom, ggproto) of length 6.

Value

A new ggproto object for a timeline label geom.

Aesthetics

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.

Examples

 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()

kfull/noaa documentation built on May 25, 2019, 8:29 p.m.