Skip to main content

contour

lq.contour(x, y, z, levels=10, fill=false, stroke=0.7pt, map=color.map.viridis, min=auto, max=auto, norm="linear", label=none, z-index=2)

Creates a contour plot for a 3-dimensional mesh. Given a set of levels, a number of cuts through the mesh are computed automatically and displayed as contour lines. Contour plots can be either just stroked

#lq.diagram(
width: 4cm, height: 4cm,
lq.contour(
lq.linspace(-5, 5, num: 12),
lq.linspace(-5, 5, num: 12),
(x, y) => x * y,
map: color.map.icefire,
)
)

or filled per-level.

#lq.diagram(
width: 4cm, height: 4cm,
lq.contour(
lq.linspace(-5, 5, num: 12),
lq.linspace(-5, 5, num: 12),
(x, y) => x * y,
map: color.map.icefire,
fill: true
)
)
Parameters

x : array

A one-dimensional array of xx data coordinates.

y : array

A one-dimensional array of yy data coordinates.

z : array | function

Specifies the zz coordinates (height) for all combinations of xx and yy coordinates. This can either be a

  • two-dimensional m×nm×n-array where mm is the length of colormesh.y and nn is the length of colormesh.x (for each yy value, a row of xx values),
  • or a function that takes an x and a y value and returns a corresponding z coordinate. Also see the function mesh that can be used to create such meshes.

levels : int | array    default: 10

Specifies the levels to compute contours for. If this is an integer, an according number of levels is automatically selected evenly from a ticking pattern. TODO: unclear. The desired levels can also be selected manually by passing an array of (zz) coordinates.

fill : bool    default: false

Whether to fill the contour levels.

stroke : stroke    default: 0.7pt

How to stroke the contours in the cases that fill: false. If this argument specifies a color, the coloring from the contour.map is overridden.

map : array | gradient    default: color.map.viridis

A color map in 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 zz 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 zz value.

norm : lq.scale | str | function    default: "linear"

The normalization method used to scale zz coordinates to the range [0,1][0,1] 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. See colormesh.norm.

label : content    default: none

The legend label for this plot. See plot.label.

z-index : int | float    default: 2

Determines the zz position of this plot in the order of rendered diagram objects. See plot.z-index.