Skip to main content

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
)
)
Parameters

x : array

An array of xx coordinates.

y : array

An array of yy coordinates. The number of xx and yy 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 size\sqrt{\mathrm{size}}.

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 the scatter.map is ignored)
  • or of type float in which case the colors are computed by normalizing the given values and passing them through scatter.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 [0,1][0,1] 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 [0,1][0,1]. Instead it describes a scaling that is applied before the data set is linearly scaled to the interval [0,1][0,1].

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 zz position of this plot in the order of rendered diagram objects. See plot.z-index.