Learn R Programming

daltoolbox (version 1.2.747)

plot_ts: Plot time series chart

Description

Simple time series plot with points and a line.

Usage

plot_ts(x = NULL, y, label_x = "", label_y = "", color = "black")

Value

returns a ggplot2::ggplot graphic

Arguments

x

time index (numeric vector) or NULL to use 1:length(y)

y

numeric series

label_x

x‑axis label

label_y

y‑axis label

color

color for the series

Details

If x is NULL, an integer index 1:n is used. The color applies to both points and line.

Examples

Run this code
x <- seq(0, 10, 0.25)
y <- sin(x)

grf <- plot_ts(x = x, y = y, color=c("red"))
plot(grf)

Run the code above in your browser using DataLab