Plot configuration recipes#
Fixed comparison window#
Use a fixed viewport to compare curves without auto-fit changing the scale underneath you.
plot(sin(x),cos(x))
// @config(viewport.autoFit=false, viewport.x.min=-pi, viewport.x.max=pi, viewport.y.min=-1.5, viewport.y.max=1.5)Interactive examples could not load. You can still copy the expressions.
Polar grid and a rose#
A polar curve and a polar grid are separate choices. The curve uses theta, and the grid setting chooses what sits behind it.
plot(sin(5*theta))
// @config(grid.type=polar, axis.y.step=0.5)Interactive examples could not load. You can still copy the expressions.
Two Y axes#
Assign a series to the right axis when the scales differ, and label the series clearly so readers know which scale to use.
plot(sin(x),100*cos(x))
// @config(series[1].yAxis=right, rightYAxis.min=-120, rightYAxis.max=120)Interactive examples could not load. You can still copy the expressions.
Per-series style#
The inline style object written directly after a series is the source of truth for that series. It is where opacity, pointShape, pointRadius, showPoints, and the other per-series fields belong, and it travels with the expression when you share it.
plot(sin(x),{color:"blue",opacity:0.4,pointShape:"circle",label:"sine"},cos(x),{color:"red",showPoints:true,pointRadius:4,label:"cosine"})Interactive examples could not load. You can still copy the expressions.
Chrome-level settings such as grid, axis, viewport, scale, legend, trace, title, plot type, and animation are different: they live on a // @config(...) directive rather than inside the style object. A style object that carries a chrome key is warned about and the key is dropped rather than silently applied.
Dynamic viewport#
Viewport bounds can depend on an animation parameter. Turn off auto-fit when you want the moving window to stay under your control.
plot(sin(x))
// @animate(T,0,2*pi,8s)
// @config(viewport.autoFit=false, viewport.x.min=T, viewport.x.max=T+2*pi)Interactive examples could not load. You can still copy the expressions.
Precedence and warnings#
An inline series style affects that series, and @config controls the plot. A field defined in the source can lock the matching panel control, so remove the source value or explicitly unlock it before editing that control.
Invalid paths and values produce a warning rather than quietly creating a new supported option. Use completion and the reference.
For ordinary calculation, choose the automatic plot evaluator. An explicitly chosen numeric evaluator may support fewer functions or scope types, so avoid changing evaluators merely to change appearance.