ggplot_stats | R Documentation |
Create a ggplot object representing a scatter plot with statistics for given amount of intervals along x-axis. Each interval contains comparable amount of data points, thus can have unequal width.
ggplot_stats(
data,
x,
y,
breaks = 20,
circular = FALSE,
ylim = NULL,
qrange = c(0.005, 0.995),
center = c("median", "mean"),
deviation = c("mad", "sd"),
header = TRUE
)
data |
A data frame with required timestamp column
( |
x , y |
A character string. A |
breaks |
An integer. Number of breakpoints separating variable |
circular |
A logical value. Is |
ylim |
Either |
qrange |
A numeric vector of length 2, giving the quantile range of y-axis. |
center , deviation |
A character string. Statistics applied to each x-axis interval for computation of its center (deviation) along y-axis. |
header |
A logical value. Should automated plot title and subtitle be included? |
circular = TRUE
effectively sets the last interval as neighboring to
the first interval. This allows to interpolate the statistics also for the
edge cases.
qrange
reduces y-axis limits to reduce the impact of outliers on plot
readability. It does not affect computed statistics. If you do not want to
limit y-axis, set qrange = NULL
or qrange = c(0, 1)
.
aggregate
, as.POSIXlt
,
cut.POSIXt
, mean
, regexp
,
strftime
, sum
, timezones
,
varnames
set.seed(123)
n <- 17520 # number of half-hourly records in one non-leap year
tstamp <- seq(c(ISOdate(2021,3,20)), by = "30 mins", length.out = n)
x <- data.frame(timestamp = tstamp,
wd = seq(0,360, length.out = n),
H = rf(n, 1, 2, 1))
openeddy::units(x) <- c("", "deg", "W m-2")
ggplot_stats(x, x = "wd", y = "H", qrange = c(0.005, 0.9))
ggplot_stats(x, x = "wd", y = "H", circular = TRUE, qrange = c(0.005, 0.9))
ggplot_stats(x, x = "wd", y = "H", ylim = "band")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.