View source: R/plot_series_comparison.R
| plot_series_comparison | R Documentation |
Plots multiple time series on the same chart for comparison.
plot_series_comparison(
data_list,
y_vars,
date_vars,
language = "eng",
scale_type = c("none", "index", "percent_change"),
title = NULL,
subtitle = NULL,
y_label = NULL,
caption = NULL,
colors = NULL,
line_types = NULL,
show_legend = TRUE,
legend_position = "bottom"
)
data_list |
Named list of data frames, each returned by a get_* function |
y_vars |
Vector of column names containing the values to plot from each data frame |
date_vars |
Vector of column names containing dates from each data frame |
language |
Language for labels: "pt" (Portuguese) or "eng" (English) |
scale_type |
Scaling applied to the series:
|
title |
Plot title |
subtitle |
Plot subtitle |
y_label |
Y-axis label |
caption |
Plot caption |
colors |
Vector of colors for each series |
line_types |
Vector of line types for each series |
show_legend |
Whether to show the legend (default: TRUE) |
legend_position |
Position of legend ("bottom", "top", "left", "right", or "none") |
A ggplot2 object
# Example comparing multiple series
selic <- get_selic_rate(2020, 2024)
ipca <- get_ipca(2020, 2024)
igpm <- get_igpm(2020, 2024)
comparison_plot <- plot_series_comparison(
data_list = list(SELIC = selic, IPCA = ipca, IGPM = igpm),
y_vars = c("value", "value", "value"),
date_vars = c("date", "date", "date"),
scale_type = "index",
title = "Comparison of Brazilian Economic Indicators",
y_label = "Index (2020-01 = 100)",
language = "eng"
)
print(comparison_plot)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.