Description Usage Format Examples
As per the course materials: The ggproto() function is used to construct a new class corresponding to your new geom. The geom_* function is constructed as a regular function. Build a geom for ggplot2 called geom_timeline() for plotting a time line of earthquakes ranging from xmin to xmaxdates with a point for each earthquake. Optional aesthetics include color, size, and alpha (for transparency). The xaesthetic is a date and an optional y aesthetic is a factor indicating some stratification in which case multiple time lines will be plotted for each level of the factor (e.g. country). This geom looks to chart a timeline of earthquakes for a given country / countries with points (in the example) representing earthquake events, point size indicating earthquake magnitude and colour representing number of deaths. x (the date) is a required aesthetic whereas y (country) is optional.
1 |
An object of class GeomTimeline
(inherits from Geom
, ggproto
, gg
) of length 5.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | ## Not run:
df <- df_earthquakes %>% filter(COUNTRY %in% c("CHINA", "USA"), YEAR > 2000)
ggplot(df, aes(x = date, y = COUNTRY,
color = as.numeric(TOTAL_DEATHS),
size = as.numeric(EQ_PRIMARY),
label = CLEAN_LOCATION_NAME)) +
geom_timeline() +
labs(size = "Richter scale value", color = "# deaths") +
ggplot2::theme(panel.background = ggplot2::element_blank(),
legend.position = "bottom",
axis.title.y = ggplot2::element_blank()) +
ggplot2::xlab("DATE")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.