Skip to content

Axes & Function Plots

<Axes> creates a 2D coordinate system with labeled tick marks, and <FunctionPlot> draws a mathematical function curve on those axes. Together they form the foundation for any math visualization.

-4-3-2-11234-2-1123
0.00s / 3.97s · F0
PropTypeDefaultDescription
origin[number, number][200, 200]Pixel position of the origin
xRange[number, number][-5, 5]Visible range on the x-axis
yRange[number, number][-5, 5]Visible range on the y-axis
scalenumber40Pixels per unit
colorstring'currentColor'Axis line color
labelColorstring'currentColor'Tick label color
showGridbooleanfalseShow background grid lines
gridColorstring'#e2e8f0'Grid line color
tickSizenumber6Length of tick marks in pixels
PropTypeDefaultDescription
fn(x: number) => numberThe function to plot
domain[number, number][-5, 5]x-domain to evaluate
origin[number, number][200, 200]Pixel position of the origin (must match Axes)
scalenumber40Pixels per unit (must match Axes)
colorstring'#4f46e5'Stroke color of the curve
strokeWidthnumber2Stroke width
samplesnumber200Number of evaluation points
elements: {
axes: {
id: 'axes',
type: 'axes',
props: { type: 'axes', origin: [250, 200], xRange: [-4, 4], yRange: [-2, 3], scale: 50, color: '$foreground', labelColor: '$foreground', showGrid: true },
},
sine: {
id: 'sine',
type: 'functionPlot',
props: { type: 'functionPlot', expression: 'sin(x)', domain: [-4, 4], origin: [250, 200], scale: 50, color: '$accent', strokeWidth: 2.5, opacity: 0 },
},
}