geom_timeline_label: A geom for labeling the timeline plot from 'geom_timeline'...

Description Usage Arguments Aesthetics Examples

View source: R/geom.R

Description

A geom for labeling the timeline plot from geom_timeline This geom labels the timeline created from geom_timeline It draws vertical lines up from the points on the timeline, with labels for the particular event. You have the option of only labeleing the top x number of events sorted by a given amount

Usage

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

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

If FALSE, the default, missing values are removed with a warning. If TRUE, missing values are silently removed.

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.

x_min

(optional) A Date object of the earliest data to be plotted

x_max

(optional) A Date object of the latest data to be plotted

top_x_mag

The top x labels to plot. For example, if earthquake occurrences are being plotted, and you only want to label the top 5 pass some measure of magnatude in the aes slot and pass 5 here

...

other arguments passed on to layer. These are often aesthetics, used to set an aesthetic to a fixed value, like color = "red" or size = 3. They may also be parameters to the paired geom/stat.

Aesthetics

geom_timeline understands the following aesthetics (required are in bold):

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
data('clean_NOAA')
NOAA <- clean_NOAA
plot_NOAA <- NOAA[NOAA$COUNTRY=="USA" | NOAA$COUNTRY=="CANADA",]
xmin <- lubridate::ymd("2010-01-01")
xmax <- lubridate::ymd("2017-07-01")
plt <- ggplot2::ggplot(data = plot_NOAA, ggplot2::aes(x = DATE, y = COUNTRY)) +
  geom_timeline(ggplot2::aes(size = EQ_PRIMARY), x_min = xmin, x_max = xmax) +
  geom_timeline_label(ggplot2::aes(label = LOCATION_NAME, magnatude = EQ_PRIMARY),
     x_min = xmin, x_max = xmax, top_x_mag = 5) +
  ggplot2::theme_minimal()
print(plt)

gravatarsmiley/capstoneR documentation built on May 30, 2019, 4:06 a.m.