| plot_line | R Documentation |
Create a line chart for one or more time series or grouped numeric variables.
plot_line(
data,
x,
y,
facet_var = NULL,
facet_scale = "free",
facet_nrow = NULL,
facet_ncol = NULL,
color = NULL,
title = NULL,
subtitle = NULL,
xlab = NULL,
ylab = NULL,
caption = NULL,
line_size = 0.75,
line_type = "solid",
line_color = "grey35",
line_alpha = 1,
theme_set = theme_tscv(),
theme_config = list(),
...
)
data |
A |
x |
Unquoted column in |
y |
Unquoted column in |
facet_var |
Optional unquoted column in |
facet_scale |
Character value defining facet axis scaling. Common values
are |
facet_nrow |
Optional integer. Number of rows in the facet layout. |
facet_ncol |
Optional integer. Number of columns in the facet layout. |
color |
Optional unquoted column in |
title |
Character value. Plot title. |
subtitle |
Character value. Plot subtitle. |
xlab |
Character value. Label for the x-axis. |
ylab |
Character value. Label for the y-axis. |
caption |
Character value. Plot caption. |
line_size |
Numeric value defining the line width. |
line_type |
Character or numeric value defining the line type. |
line_color |
Character value defining the line color. Ignored when
|
line_alpha |
Numeric value between |
theme_set |
A complete |
theme_config |
A named |
... |
Currently not used. |
plot_line() is a convenience wrapper around ggplot2::geom_line()
for plotting data in long format. It supports optional grouping by color,
optional faceting, and the default tscv theme.
The arguments x, y, facet_var, and color are
passed as unquoted column names.
If color is supplied, line colors are mapped to that variable and
line_color is ignored. If color is not supplied, all lines are
drawn using line_color.
Additional theme settings can be supplied through theme_config. This
should be a named list of arguments passed to ggplot2::theme().
An object of class ggplot.
Other data visualization:
plot_bar(),
plot_density(),
plot_histogram(),
plot_point(),
plot_qq(),
scale_color_tscv(),
scale_fill_tscv(),
theme_tscv(),
tscv_cols(),
tscv_pal()
library(dplyr)
data <- M4_monthly_data |>
filter(series %in% c("M23100", "M14395"))
plot_line(
data = data,
x = index,
y = value,
facet_var = series,
title = "M4 Monthly Time Series",
subtitle = "Selected monthly series from the M4 forecasting competition",
xlab = "Time",
ylab = "Value",
caption = "Data: M4 Forecasting Competition"
)
plot_line(
data = data,
x = index,
y = value,
color = series,
title = "M4 Monthly Time Series",
xlab = "Time",
ylab = "Value",
line_size = 1.5
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.