colormesh
lq.colormesh(x, y, z, map=color.map.viridis, min=auto, max=auto, excess="clamp", norm="linear", interpolation="pixelated", label=none, z-index=2)(source)Plots a rectangular color mesh, e.g., a heatmap.
#lq.diagram(
width: 4cm, height: 4cm,
lq.colormesh(
lq.linspace(-4, 4, num: 10),
lq.linspace(-4, 4, num: 10),
(x, y) => x * y,
map: color.map.magma
)
)
When the input x and y coordinate arrays are both evenly spaced, an
image is drawn instead of individual rectangles. This reduces the file size
and improves rendering in most cases. When either array is not evenly
spaced, the entire color mesh is drawn with individual rectangles.
x : array
A one-dimensional array of coordinates.
y : array
A one-dimensional array of coordinates.
z : array | function
Specifies the coordinates (height) for all combinations of and coordinates. This can either be a
- two-dimensional -array where is the length of
colormesh.yand is the length ofcolormesh.x(for each value, a row of values), - or a function that takes an
xand ayvalue and returns a correspondingzcoordinate. Also see the functionmeshthat can be used to create such meshes.
For masking, you can use float.nan values to hide individual cells of the color mesh.
map : array | gradient default: color.map.viridis
A color map in the form of a gradient or an array of colors to sample from.
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.
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.
excess : "clamp" | "mask" default: "clamp"
Determines how values outside the range defined by colormesh.min and
colormesh.max are handled.
"clamp": Values belowcolormesh.minare mapped to the first color of the color map, values abovecolormesh.maxare mapped to the last color."mask": Values outside the range are not drawn and appear transparent.
norm : lq.scale | str | function default: "linear"
The normalization method used to scale coordinates to the range
before mapping them to colors using 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 the argument 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 .
interpolation : "pixelated" | "smooth" default: "pixelated"
Whether to apply smoothing or leave the color mesh pixelated. This is
currently only supported when colormesh.x and colormesh.y are evenly
spaced.
label : content default: none
The legend label for this plot. See plot.label.
z-index : int | float default: 2
Determines the position of this plot in the order of rendered diagram
objects. See plot.z-index.