Description Usage Arguments Details Value Examples
Plot time series in the style of the California Current IEA. Dashed lines are
used in between missing data and points colored by color_pts
. Include a
ribbon around y
if low (y_lo
) and high (y_hi
) values are provided.
Include long-term average if add_avg = TRUE
with average as a black
dashed line and solid lines indicating the standard deviation in the color
of color_avg
. Include rectangle in the color of color_avg
between the
standard deviation of the long-term average since x_recent
if provided.
Include icons in the right-hand margin for recent trend (→, ↗, ↘) and
recent average (o, +, -) if stable, increasing, or decreasing (respectively)
relative to the long-term standard deviation.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | plot_ts(
d,
x = year,
y = index,
y_lo = SElo,
y_hi = SEup,
x_recent = 5,
units_recent = "years",
add_avg = TRUE,
add_icons = TRUE,
font_size = 24,
icon_size = font_size/2,
color_pts = rgb(225, 118, 44, max = 255),
color_avg = rgb(63, 173, 213, max = 255),
color_hilo = "lightgrey",
alpha_avg = 0.8,
alpha_hilo = 0.8,
theme_plot = theme_iea
)
|
d |
Default dataset to use for plotting with
|
x |
column for x axis from |
y |
column for y axis from |
y_lo |
unquoted column for low value to apply to gray ribbon, typically
|
y_hi |
unquoted column for highy value to apply to gray ribbon, typically
|
x_recent |
duration of |
units_recent |
units to describe |
add_avg |
whether to add average as a black dashed line and solid lines
indicating the standard deviation in the color of |
add_icons |
whether to include icons in the right-hand margin for recent
trend (→, ↗, ↘) and recent average (o, +, -) if stable, increasing, or
decreasing (respectively) relative to the long-term standard deviation.
Defaults to |
font_size |
font size. Defaults to 24. |
icon_size |
size of icon font. Defaults to half the |
color_pts |
color for points, as named color (see
|
color_avg |
color for standard deviation lines around long-term average
and rectangle between since |
color_hilo |
color for ribbon around |
alpha_avg |
transparency (0 to 1) for colored elements of long-term average: standard deviation and recent rectangle. |
alpha_hilo |
transparency (0 to 1) for ribbon around |
theme_plot |
theme function to apply to the ggplot. Defaults to
|
The attribute caption
includes a textual summary.
This function returns a ggplot object with attributes for: caption
,
recent_trend
and recent_avg
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | # example time series dataset with some NAs to show dashed line between non-NA values
ts1
# defaults to include all options data frame contains x, y, SElo, SEhi
g <- plot_ts(ts1)
g
# show the caption attributed to the returned ggplot object
cat(attr(g, "caption"))
# without SElo or SEhi columns, just year and index
g <- plot_ts(ts1[,c("year","index")])
g
# same caption as previously, since defaults to x_recent=5 and add_avg=T
cat(attr(g, "caption"))
# without default x_recent, add_avg, or add_icons
g <- plot_ts(ts1, x_recent=NA, add_icons=F, add_avg=F)
g
# no caption, since missing x_recent and add_avg
cat(attr(g, "caption")) # empty caption without x_recent
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.