geom_timeline_label: Plot Timeline Label Geom

Description Usage Arguments Value Aesthetics Examples

View source: R/geom_functions.R

Description

The function geom_timeline plots a timeline label geom labels to one or many timelines of earthquakes.

Usage

1
2
3
geom_timeline_label(mapping = NULL, data = NULL, stat = "identity",
  position = "identity", na.rm = TRUE, show.legend = NA,
  inherit.aes = TRUE, ...)

Arguments

mapping

Set of aesthetic mappings created by aes or aes_. If specified and inherit.aes = TRUE (the default), it is combined with the default mapping at the top level of the plot. You must supply mapping if there is no plot mapping.

data

The data to be displayed in this layer. There are three options:

If NULL, the default, the data is inherited from the plot data as specified in the call to ggplot.

A data.frame, or other object, will override the plot data. All objects will be fortified to produce a data frame. See fortify for which variables will be created.

A function will be called with a single argument, the plot data. The return value must be a data.frame., and will be used as the layer data.

stat

The statistical transformation to use on the data for this layer, as a string.

position

Position adjustment, either as a string, or the result of a call to a position adjustment function.

na.rm

Boolean indicating wheather to remove NA values.

show.legend

logical. Should this layer be included in the legends? NA, the default, includes if any aesthetics are mapped. FALSE never includes, and TRUE always includes.

inherit.aes

If FALSE, overrides the default aesthetics, rather than combining with them. This is most useful for helper functions that define both data and aesthetics and shouldn't inherit behaviour from the default plot specification, e.g. borders.

...

Additional optional parameters.

Value

The function geom_timeline_label plots 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.