Creates line plots of time series with Insper's visual identity. Handles
Date and POSIXct x-axes and both discrete and continuous color
mappings.
Usage
insper_timeseries(
data,
x,
y,
color = NULL,
palette = "main",
line_width = 0.8,
add_points = FALSE,
...
)Arguments
- data
A data frame.
- x
<
data-masked> Time variable (numeric,Date, orPOSIXct).- y
<
data-masked> Value variable.- color
Color aesthetic. Accepts one of the options below.
A bare column name, mapped to color, one line per group (e.g.,
color = category).A quoted color string, used as a static color (e.g.,
color = "blue").NULL(default), which uses Insper turquesa.
A mapped variable gets a discrete or continuous Insper scale to match its type.
- palette
Character. Palette for mapped variables. Default is
"main".- line_width
Numeric. Line width. Default is 0.8.
- add_points
Logical. If
TRUE, adds points on the lines. Default isFALSE.- ...
Additional arguments passed to
ggplot2::geom_line(), such aslinetypeoralpha.
Examples
if (FALSE) { # has_insper_fonts()
library(ggplot2)
# Plot inflation over time
insper_timeseries(macro_series, x = date, y = ipca)
# A quoted color string sets a static line color
insper_timeseries(macro_series, x = date, y = ipca, color = "#3ACC9F")
# Grouped time series (discrete variable)
recent_data <- subset(fossil_fuel, year >= 1920)
insper_timeseries(recent_data, x = year, y = consumption, color = fuel)
}
