plot
lq.plot(x, y, xerr=none, yerr=none, color=auto, stroke=auto, mark=auto, mark-size=auto, mark-color=auto, step=none, smooth=false, every=none, label=none, clip=true, z-index=2)(source)
Standard plotting method for 2d data with lines and/or marks and optional
error bars. Points where the or coordinate is nan
are skipped.
#let x = lq.linspace(0, 10)
#lq.diagram(
lq.plot(x, x.map(x => calc.sin(x)))
)
By default, the line and mark style is determined by the current diagram.cycle
.
However, they can be configured per plot with the options plot.color
, plot.mark
,
and plot.stroke
.
This function is also intended for creating plots with error bars.
Error bars can be styled through the errorbar
type.
#lq.diagram(
lq.plot(
range(8), (3, 6, 2, 6, 5, 9, 0, 4),
yerr: (1, 1, .7, .8, .2, .6, .5, 1),
stroke: none,
mark: "star",
mark-size: 6pt
)
)
x : array
An array of coordinates. Data coordinates need to be of type int
or float
.
y : array
An array of coordinates. The number of and coordinates must match.
xerr : none
| array
| dictionary
default: none
Optional errors/uncertainties for coordinates. Symmetric errors can be specified as a
- a constant (e.g.,
xerr: 1.5
) or - an array with the same length as
plot.x
for individual errors per data point (e.g.,xerr: (0.5, 1, 1.5)
).
Asymmetric errors can be given as
- a dictionary with the keys
p
(plus) andm
(minus) with either a constant value or arrays with the same length asplot.x
(e.g.,xerr: (p: 1, m: 2)
) or - an array of dictionaries per data point, each filled with single
p
andm
values (e.g.,xerr: ((p: 1, m: 2), (p: 2, m: 3))
).
The look of the error bars can be controlled through the type errorbar
.
yerr : none
| array
default: none
Optional errors/uncertainties for coordinates. See plot.xerr
.
The look of the error bars can be controlled through errorbar
.
color : auto
| color
default: auto
Combined color for line and marks. See also the parameters plot.stroke
and
plot.mark-fill
which take precedence over color
, if set.
stroke : auto
| stroke
default: auto
The line style to use for this plot (takes precedence over plot.color
).
mark : auto
| none
| lq.mark
| string
default: auto
The mark to use to mark data points. This may either be a mark (such as
lq.mark.x
) or a registered mark string, see mark
.
mark-size : auto
| length
default: auto
Size of the marks. For variable-size mark plots, use the plot type scatter
.
mark-color : auto
| color
default: auto
Color of the marks (takes precedence over plot.color
).
TODO: this parameter should eventually be removed. Instead one
would be able to set mark color and stroke through
#lq.diagram(
plot(..), // normal plot
{
set mark(fill: red, stroke: black)
plot(..)
}
)
This again reduces the API. mark.size
however is common enough to deserve
its own parameter.
step : none
| start
| end
| center
default: none
Step mode for plotting the lines.
none
: Consecutive data points are connected with a straight line.start
: The interval takes the value of .center
: The value switches half-way between consecutive positions.end
: The interval takes the value of .
Details
#import "@preview/lilaq:0.4.0" as lq
#lq.diagram(
lq.plot(
range(8), (3,6,2,6,5,9,0,4),
step: center
)
)
smooth : bool
default: false
Interpolates the data set using Bézier splines instead of connecting the points with straight lines.
Note: If two or fewer points are given, linear interpolation is used.
Details
#import "@preview/lilaq:0.4.0" as lq
#lq.diagram(
lq.plot(
range(8), (3, 6, 2, 6, 5, 9, 0, 4),
smooth: true
)
)