Description Usage Arguments Details Value Examples
View source: R/geom_timeline_label.R
Module 2: Visualization Tools: Visualize the times at which earthquakes occur within certain countries This geom adds a vertical line to each data point with a text annotation (e.g. the location of the earthquake) attached to each line. There should be an option to subset to n_max number of earthquakes, where we take the n_max largest (by magnitude) earthquakes. Aesthetics are x, which is the date of the earthquake and label which takes the column name from which annotations will be obtained.
1 2 3 4 5 6 7 8 9 10 |
mapping |
The mappings created. |
data |
The data need to display in this layer. |
stat |
The statistical transformation to use on the data for this layer. |
position |
Position adjustment |
na.rm |
Missing values are removed with if false |
show.legend |
logical. This layer be included in the legends or not |
inherit.aes |
Override the default aesthetic if false |
... |
Other arguments passed on to [layer()].
|
The data downloaded and readed from https://www.ngdc.noaa.gov/nndc/struts/form?t=101650&s=1&d=1.
The geom geom_timeline_label
used with the ggplot
function
and the geom_timeline
geom, add annotations to the n_max largest (by magnitude) earthquakes.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | # The data must be cleaned using the function \code{eq_clean_data}, included in the package.
# The LOCATION_NAME colomn of the data must be cleaned using the function \code{eq_location_clean},
# included in the package.
# Aesthetics can be specified in the \code{ggplot} function or in \code{geom_timeline} geom function
## Not run:
data <- readr::read_delim("signif.txt", delim = "\t")
data <- eq_clean_data(data)
data <- eq_location_clean(data)
data %>%
dplyr::filter(COUNTRY == c("CANADA","USA") & lubridate::year(DATE) >= 2010) %>%
ggplot(aes(x=DATE,y=COUNTRY,color=TOTAL_DEATHS,size=EQ_PRIMARY)) +
geom_timeline(alpha=.5) +
geom_timelinelabel(aes(label=LOCATION_NAME),n_max=5) +
theme(legend.position="bottom", legend.box="horizontal", plot.title=element_text(hjust=0.5)) +
ggtitle("Earthquakes Visualization") +
labs(size = "Richter scale", color = "# deaths")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.