View source: R/histogram_plot.R
histogram_plot | R Documentation |
Returns a histogram using ggplot2
for each element and
station given. Takes a data frame as an input and the relevant columns to
create the plot.
histogram_plot(
data,
date_time,
elements,
station = NULL,
facet_by = c("stations", "elements", "stations-elements", "elements-stations",
"none"),
position = c("identity", "dodge", "dodge2", "stack", "fill", "layer"),
colour_bank = NULL,
na_rm = FALSE,
orientation = NA,
show_legend = NA,
width = NULL,
facet_nrow = NULL,
facet_ncol = NULL,
title = "Histogram Plot",
x_title = NULL,
y_title = NULL
)
data |
|
date_time |
|
elements |
|
station |
|
facet_by |
|
position |
|
colour_bank |
|
na_rm |
|
orientation |
The orientation of the layer. The default ( |
show_legend |
|
width |
Bar width. By default, set to 90% of the resolution of the data. |
facet_nrow |
|
facet_ncol |
|
title |
|
x_title |
|
y_title |
|
a ggplot
object.
data("daily_niger")
# Create a histogram plot with facets by both elements and stations
data(daily_niger)
daily_niger_1 <- daily_niger %>% dplyr::filter(year < 1950)
histogram_plot(data = daily_niger_1, date_time = "date",
facet_by = "stations-elements",
elements = c("tmax", "tmin"), station = "station_name")
# Can make additional changes to the plot since the returned object is a \code{ggplot2} object
# for example, to edit the colours in the plot:
require(ggplot2)
t1 <- histogram_plot(data = daily_niger_1, date_time = "date", elements = c("rain", "tmax"),
position = "dodge", station = "station_name")
t1 + ggplot2::scale_colour_discrete(type = c("red", "black"))
# Can additionally layer elements in a single plot
histogram_plot(data = daily_niger_1, date_time = "date", position = "layer",
facet_by = "stations",
elements = c("tmax", "tmin"), station = "station_name",
colour_bank = c("purple", "orange"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.