Draw a Line Chart
draw_line.RdQuick line chart from x/y data.
Usage
draw_line(
x,
y,
names = NULL,
smooth = FALSE,
area = FALSE,
points = TRUE,
blocks = NULL,
block_color = NULL,
block_opacity = 0.2,
color = NULL,
xlim = NULL,
ylim = NULL,
xlab = NULL,
ylab = NULL,
title = NULL,
theme = NULL,
zoom = FALSE,
margins = NULL,
width = NULL,
height = NULL,
filename = NULL
)Arguments
- x
Vector: X-axis values.
- y
Numeric or named list: Y values.
- names
Optional Character: Series names used when
yis an unnamed list.- smooth
Logical: Whether to smooth lines.
- area
Logical: Whether to show area fill.
- points
Logical: Whether to show point markers on each data value. Defaults to
TRUE; set toFALSEon long time-series where the symbols add visual noise.- blocks
Optional factor, integer, character, or logical of length
length(x): Per-x-value group label used to shade vertical background bands. Contiguous runs of the same level become one band.NAentries produce no band.- block_color
Optional Character vector or list of length k, where k is the number of unique levels in
blocks: Fill color for each level. Match by name to factor levels if named, else positional.NA,NULL, or"transparent"entries skip that level.- block_opacity
Numeric [0, 1]: Fill opacity applied to all bands. Defaults to
0.2.- color
Optional Character: Series color palette — a single color string or character vector that overrides the theme palette for this chart.
colortakes precedence over the theme palette (it setsoption.color).- xlim
Optional Numeric [length 2]: X-axis limits
c(min, max). Only supported whenxis numeric; passingxlimwith a non-numericxerrors. Defaults torange(x)(no padding) whenxis numeric.- ylim
Optional Numeric [length 2]: Y-axis limits
c(min, max). Defaults to the range of allyvalues across series (no padding).- xlab
Optional Character: X-axis title.
- ylab
Optional Character: Y-axis title.
- title
Optional Character: Chart title.
- theme
Optional Theme: Theme override. The palette inside the theme can be overridden per-chart with the
colorargument.- zoom
Logical, DataZoom, or list of DataZoom: Enable x-axis zoom.
TRUEadds a slider plus mouse-wheel/drag zoom on the x-axis;FALSE(default) disables zoom. Pass DataZoom objects (or a list of them) for full control over zoom behavior and styling.- margins
Optional Named numeric vector or named list: Plot margins in pixels (or percentage strings) for any of
"top","right","bottom","left"— e.g.c(left = 80, right = 20)orlist(left = 80, right = "10%"). Unspecified sides keep echarts' default auto-sizing (outerBoundsMode = "same"), which shrinks the grid to fit axis labels and names with no dead space.- width
Optional Character or Numeric: Widget width.
- height
Optional Character or Numeric: Widget height.
- filename
Optional Character: If provided, save the widget to this file via
save_drawing().