View source: R/timeseries_plot.R
timeseries_plot | R Documentation |
Returns a timeseries plot using ggplot2
for each element
and station given. Takes a data frame as an input and the relevant columns to
create the plot.
timeseries_plot(
data,
date_time,
elements,
station = NULL,
facet_by = c("stations", "elements", "stations-elements", "elements-stations",
"none"),
type = c("line", "bar"),
add_points = FALSE,
add_line_of_best_fit = FALSE,
se = TRUE,
add_path = FALSE,
add_step = FALSE,
na_rm = FALSE,
show_legend = NA,
title = "Timeseries Plot",
x_title = NULL,
y_title = NULL
)
data |
|
date_time |
|
elements |
|
station |
|
facet_by |
|
type |
|
add_points |
|
add_line_of_best_fit |
|
se |
|
add_path |
|
add_step |
|
na_rm |
|
show_legend |
|
title |
|
x_title |
|
y_title |
|
a ggplot
object.
# Create a time series plot with two elements and facet by station.
data(daily_niger)
daily_niger_1 <- daily_niger %>% dplyr::filter(year < 1950)
timeseries_plot(data = daily_niger_1, date_time = "date", elements = c("tmax", "tmin"),
station = "station_name", facet_by = "stations")
# Can make additional changes to the plot since the returned object is a \code{ggplot2} object
# for example, to add colour-blind friendly colours instead of the default colours
require(ggplot2)
t1 <- timeseries_plot(data = daily_niger_1, date_time = "date", elements = c("tmax", "tmin"),
station = "station_name", facet_by = "stations")
t1 + ggplot2::scale_colour_discrete(type = c("#E69F00", "#56B4E9"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.