scatter
lq.scatter(x, y, size=auto, color=auto, map=color.map.viridis, min=auto, max=auto, norm="linear", mark=auto, stroke=1pt, alpha=100%, label=none, clip=true, z-index=2)(source)
Produces a scatter plot from the given coordinates. The mark size and
color can be set per point (this discerns scatter
from plot
).
#import "@preview/suiji:0.3.0"
#let rng = suiji.gen-rng(33)
#let (rng, x) = suiji.uniform(rng, size: 20)
#let (rng, y) = suiji.uniform(rng, size: 20)
#let (rng, colors) = suiji.uniform(rng, size: 20)
#let (rng, sizes) = suiji.uniform(rng, size: 20)
#lq.diagram(
lq.scatter(
x, y,
size: sizes.map(size => 200 * size),
color: colors,
map: color.map.magma
)
)
x : array
An array of coordinates.
y : array
An array of coordinates. The number of and coordinates must match.
size : auto
| array
default: auto
How to scale the marks. The area of the marks scales proportionally with these numbers while the actual mark "size" (e.g., width) will scale with .
color : auto
| color
| array
default: auto
How to fill the marks. A single color can be used to override the default cycle fill style.
When given per-point as an array, the values may either be of type
color
(then thescatter.map
is ignored)- or of type
float
in which case the colors are computed by normalizing the given values and passing them throughscatter.map
.
map : array
| gradient
default: color.map.viridis
A color map in the form of a gradient or an array of colors to sample from when
scatter.color
is given as a float
array.
min : auto
| int
| float
default: auto
Sets the data value that corresponds to the first color of the color map. If set
to auto
, it defaults to the minimum value of scatter.color
.
max : auto
| int
| float
default: auto
Sets the data value that corresponds to the last color of the color map. If set
to auto
, it defaults to the maximum value of scatter.color
.
norm : lq.scale
| str
| function
default: "linear"
The normalization method used to scale float
scatter.color
values to
the range before mapping them to colors with the color map. This
can be
- a
scale
, - a string that is the identifier of a built-in scale, or
- a function that takes one argument (for example
x => calc.log(x)
would be equivalent to passing"log"
). Note that the function does not actually need to map the values to the interval . Instead it describes a scaling that is applied before the data set is linearly scaled to the interval .
mark : auto
| lq.mark
| string
default: auto
The mark to use to mark data points. See plot.mark
.
stroke : stroke
default: 1pt
Mark stroke. TODO: need to get rid of it
alpha : ratio
| array
default: 100%
The fill opacity. TODO: maybe get rid of it, there is already color.
label : content
default: none
The legend label for this plot. See plot.label
.
clip : bool
default: true
Whether to clip the plot to the data area. See plot.clip
.
z-index : int
| float
default: 2
Determines the position of this plot in the order of rendered diagram
objects. See plot.z-index
.