The same plot in 14 other libraries — Python: Altair, Bokeh, lets-plot, Matplotlib, Plotly, plotnine, Pygal, Seaborn; Julia: Makie.jl; JavaScript: Chart.js, D3.js, Apache ECharts, Highcharts, MUI X Charts. Compare all 15 side by side: Time Series Line Plot in Python, R, Julia and JavaScript.
A time series line plot displays data points connected by lines over a datetime x-axis, with smart date formatting that automatically adjusts tick labels based on the time scale (days, months, years). This plot type is essential for temporal data analysis where proper date formatting and readability are critical. Unlike basic line plots, time series plots handle datetime parsing, timezone awareness, and intelligent tick label formatting.

#' anyplot.ai
#' line-timeseries: Time Series Line Plot
#' Library: ggplot2 4.0.3 | R 4.6.1
#' Quality: 83/100 | Updated: 2026-10-29
library(ggplot2)
library(scales)
library(ragg)
# --- Theme tokens -----------------------------------------------------------
THEME <- Sys.getenv("ANYPLOT_THEME", "light")
PAGE_BG <- if (THEME == "light") "#FAF8F1" else "#1A1A17"
INK <- if (THEME == "light") "#1A1A17" else "#F0EFE8"
INK_SOFT <- if (THEME == "light") "#4A4A44" else "#B8B7B0"
GRID <- scales::alpha(INK, 0.15) # faint grid — element_line has no alpha arg
MUTED <- if (THEME == "light") "#6B6A63" else "#A8A79F" # Imprint muted anchor — trend line
IMPRINT_PALETTE <- c("#009E73", "#C475FD", "#4467A3", "#BD8233",
"#AE3030", "#2ABCCD", "#954477", "#99B314") # Imprint palette
# --- Columns: set these to your table's column names -------------------------
DATE <- "Date" # role: x (date)
TEMPERATURE <- "Outdoor Temperature (°C)" # role: y (value)
# --- Data: replace this block with your own table, for example
# df <- read.csv("temperature.csv", check.names = FALSE); df[[DATE]] <- as.Date(df[[DATE]])
# Six months of daily outdoor temperature readings with a seasonal warm-up
# trend, weekly wobble, and day-to-day sensor noise.
set.seed(42)
n_days <- 182
day_idx <- seq_len(n_days)
seasonal_trend <- 4 + 14 * sin(2 * pi * (day_idx - 109) / 365)
weekly_wobble <- 1.2 * sin(2 * pi * day_idx / 7)
sensor_noise <- rnorm(n_days, mean = 0, sd = 1.6)
df <- tibble::tibble(
!!DATE := seq(as.Date("2024-01-01"), by = "day", length.out = n_days),
!!TEMPERATURE := seasonal_trend + weekly_wobble + sensor_noise
)
# --- Plot: reads only df and the constants above ----------------------------
p <- ggplot(df, aes(x = .data[[DATE]], y = .data[[TEMPERATURE]])) +
geom_smooth(
method = "loess", span = 0.3, se = FALSE,
color = MUTED, linewidth = 0.8, linetype = "dashed"
) +
geom_line(color = IMPRINT_PALETTE[1], linewidth = 2) +
scale_x_date(
date_breaks = "1 month",
labels = scales::label_date("%b")
) +
scale_y_continuous(labels = scales::label_number(suffix = "°C")) +
labs(
title = "line-timeseries · r · ggplot2 · anyplot.ai",
x = DATE,
y = TEMPERATURE
) +
theme_minimal(base_size = 8) +
theme(
plot.background = element_rect(fill = PAGE_BG, color = PAGE_BG),
panel.background = element_rect(fill = PAGE_BG, color = NA),
panel.grid.major = element_line(color = GRID, linewidth = 0.4),
panel.grid.minor = element_blank(),
panel.border = element_blank(),
axis.line = element_line(color = INK_SOFT, linewidth = 0.4),
axis.ticks = element_blank(),
axis.title = element_text(color = INK, size = 10),
axis.text = element_text(color = INK_SOFT, size = 8),
plot.title = element_text(color = INK, size = 12, face = "bold"),
plot.margin = margin(t = 14, r = 20, b = 10, l = 10)
)
# --- Save -------------------------------------------------------------------
ggsave(
filename = sprintf("plot-%s.png", THEME),
plot = p,
device = ragg::agg_png,
width = 8,
height = 4.5,
units = "in",
dpi = 400
)
Runnable source as JSON, for any HTTP client: https://api.anyplot.ai/specs/line-timeseries/ggplot2/code. Any spec id and library id listed in llms-full.txt fit the same URL shape; every URL below is complete and callable.
{
"spec_id": "line-timeseries",
"language": "r",
"library": "ggplot2",
"page": "https://anyplot.ai/line-timeseries/r/ggplot2",
"hub": "https://anyplot.ai/line-timeseries",
"code_json": "https://api.anyplot.ai/specs/line-timeseries/ggplot2/code",
"spec_json": "https://api.anyplot.ai/specs/line-timeseries",
"render_light_png": "https://storage.googleapis.com/anyplot-images/plots/line-timeseries/r/ggplot2/plot-light.png",
"render_dark_png": "https://storage.googleapis.com/anyplot-images/plots/line-timeseries/r/ggplot2/plot-dark.png",
"quality_score": 83.0,
"license": "MIT",
"guide": "https://anyplot.ai/llms.txt"
}Part of Time Series Line Plot on anyplot.ai.