plot_sei {SEI} | R Documentation |
Plot standardised indices
Description
Plot a time series containing standardised indices, or a histogram of the indices.
Usage
plot_sei(
x,
type = c("ts", "hist", "bar"),
title = NULL,
lab = "Std. Index",
xlims = NULL,
ylims = NULL,
n_bins = 30
)
Arguments
x |
vector or xts object containing the indices to be plotted. |
type |
type of plot (either time series "ts", histogram "hist", or barplot "bar"). |
title |
optional title of the plot. |
lab |
axis label. |
xlims , ylims |
lower and upper limits of the axes. |
n_bins |
the number of bins to show in the histogram. |
Details
The plot_sei()
function can be used to plot either a time series (if type = "ts"
)
or a histogram (if type = "hist"
or type = "bar"
) of the values in x
.
A time series can only be displayed if x
is an xts time series.
The argument lab
is a string containing the label of the x-axis if
type = "hist"
or type = "bar"
and the y-axis if type = "ts"
.
The options type = "hist"
and type = "bar"
both display histograms
of the data x
. With type = "hist"
, plot_sei()
is essentially a
wrapper of geom_histogram()
, while type = "bar"
is a wrapper of
geom_bar()
. The latter can provide more flexibility when plotting bounded data,
whereas the former is easier to use when superimposing densities on top.
Value
A ggplot object displaying the standardised index values.
Author(s)
Sam Allen, Noelia Otero
Examples
data(data_supply)
# consider hourly German energy supply data in 2019
supply_de <- subset(data_supply, country == "Germany", select = c("date", "PWS"))
supply_de <- xts::xts(supply_de$PWS, order.by = supply_de$date)
supply_de_std <- std_index(supply_de, timescale = "hours")
plot_sei(supply_de, title = "German renewable energy production in 2019")
plot_sei(supply_de_std, title = "German SREPI in 2019")
plot_sei(supply_de, type = "hist", title = "German renewable energy production in 2019")
plot_sei(supply_de_std, type = "hist", title = "German SREPI in 2019")