API reference
The practical plotting surface, with links to the exact source used by this website.
Data figures
Import from typeplot or typeplot/data. Both include the TypeShade runtime without the compiler. The figure handle is synchronous; await fig.ready for the first complete GPU frame and handle renderer failures.
plot(y, options?)Create a Figure with x coordinates taken from array indices.plot(x, yOrFunction, options?)Draw arrays, typed arrays or a JavaScript callback.subplots(rows?, cols?, options?)Return { fig, axes }; axes is always a flat row-major array.figure(options?)Create an empty Figure; draw with fig.axes[0].linspace(start, stop, count = 50)Return a Float64Array including both endpoints.ax.plot / scatter / bar / histogramAdd a series. histogram returns { counts, bins, series }.ax.set(options)Set title, xLabel, yLabel, grid, legend, xLimits/yLimits and xScale/yScale.ax.setXLimits / setYLimitsFix a range. autoscale() restores automatic ranges.series.setData / removeReplace copied data or remove one series.fig.saveImage / toBlob / destroyDownload PNG, obtain PNG bytes, or release the figure.
Style and axes options
Series styles use label, color, lineWidth, lineStyle, marker, markerSize and alpha. Line styles are -, --, : and none. Markers are o, s and none. Axes can have linear or log xScale/yScale, fixed xLimits/yLimits, titles, labels, grids and legends.
ax.plot(x, y, {
label: "Measurements", color: "#1677ff",
lineWidth: 2, lineStyle: "--", marker: "o", markerSize: 3,
});
ax.set({ xScale: "log", xLimits: [1, 100], grid: true });Histograms
bins accepts a count from 1 to 10000 or finite strictly increasing edges. The final bin includes its right endpoint. density: true normalizes the total bar area to one. NaN and infinity are ignored. Remove and recreate a histogram to change its bins.
GPU programs
Compile with typeplot/compiler or the Vite plugin, then mount using createPlot(canvas, program, options). The original plot(canvas, program, options) form remains supported.
compilePlot(source, options)Build-time scalar or parametric callback compilation.createPlot(canvas, program, options)Return a Promise<Plot> with its actual backend.plot.setParameters(values)Update declared finite f32 parameters; unknown names are rejected.plot.setMode / setProbe / boundsSwitch 2D/3D mode, select perspective/orthographic projection, set the probe or read bounds.plot.reset / redraw / destroyRestore initial settings, request a frame, or release resources.
Export and lifecycle
Figure.toBlob() returns a PNG Blob; saveImage() initiates a PNG download. Export size is independent of the displayed size. The budget is 16 megapixels with a 16384-pixel dimension limit. destroy() is idempotent and releases observers, interaction listeners, pending frames and owned DOM.