Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help


ax_contour (expr, xvar, xlo, xhi, yvar, ylo, yhi) — Function

Filled contour plot of a 2D expression. Use inside ax_draw2d. Samples f(x,y) on a grid and renders as a Plotly contour chart with multiple filled levels.

Distinct from implicit() which renders a single contour line at f(x,y)=0.

Examples

/* Basic contour plot */
ax_draw2d(ax_contour(x^2 + y^2, x, -3, 3, y, -3, 3))$

/* With colorscale and contour count */
ax_draw2d(
  ax_contour(sin(x)*cos(y), x, -%pi, %pi, y, -%pi, %pi),
  colorscale="Viridis", ncontours=20,
  title="sin(x)*cos(y)"
)$

/* Hide colorbar */
ax_draw2d(
  ax_contour(x*y, x, -2, 2, y, -2, 2),
  showscale=false
)$

Relevant Options

OptionDefaultDescription
colorscaleautoColor scale: "Viridis", "Hot", "Blues", etc.
ncontoursautoNumber of contour levels
showscaleautoShow/hide the color bar
nticks80Grid sampling resolution
nameautoLegend entry
opacity1.0Trace opacity

See also: ax_draw2d, ax_heatmap, implicit