Description Usage Arguments Value Note Examples
View source: R/earthquake_functions.R
This function adds a geom which displays labels for points on a timeline for NOAA earthquake data. This is the basic label visualization without additional modifications. For a cleaner visualization the wrapper function, eq_time, should be used.
1 2 3 |
mapping |
A set of aesthetic mappings. If null, uses the default setting in ggplot() |
data |
A dataset If null, uses the default data specified in ggplot() |
stat |
The name of the statistical transformation to use. Identity means keep the data as is. |
position |
The method used to adjust overlapping objects. Identity means keep the position as is. |
na.rm |
Flag to remove values with NA |
show.legend |
Flag to say whether layer should be present in legend. |
inherit.aes |
Flag to say whether default aesthetics should be inherited. |
n_max |
The number of earthquakes to be labeled. The earthquakes with n_max highest magnitudes will be labeled. |
... |
Additional arguments passed to layer() |
This function returns a layer that can be added to a plot using the ggplot function
The parameters for GeomTimeLineLabel include columns from the earthquake data: Required parameters: x=DATE, label=LOCATION_NAME Optional parameters: n_max=x where x is the number of earthquakes with the highest magnitude to label.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | ## Not run:
sample_USA <- readr::read_delim(filename, delim = "\t") %>%
eq_clean_data() %>%
dplyr::filter(COUNTRY == "USA" & lubridate::year(DATE) >= 2000)
ggplot(data = sample_USA, aes(x=DATE)) + geom_timeline() +
geom_timeline_label(data=sample_USA,aes(label=LOCATION_NAME),n_max=8) + theme_classic()
ggplot() +
geom_timeline_label(data=sample_USA,aes(x=DATE,label=LOCATION_NAME))
sample_2_countries<- readr::read_delim(filename, delim = "\t") %>%
eq_clean_data() %>%
dplyr::filter((COUNTRY=="USA" | COUNTRY=="CHINA") & lubridate::year(DATE) >= 2000)
ggplot() +
geom_timeline_label(data=sample_2_countries,aes(x=DATE,y=COUNTRY,label=LOCATION_NAME))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.