Skip to main content

Function plot

Plots a mathematical function (or several functions) as a graph.

Syntax

```plot
{"data":[{"fn":"x^2"},{"fn":"sin(x)","color":"red"}],"xDomain":[-5,5]}
```

The code language is plot (this isn't LaTeX's "function plot"; you simply write plot). The content is a JSON object that defines the functions to plot and, optionally, the axis range: each item in the data array carries an fn (function expression) and an optional color, and xDomain sets the range of the x-axis.

What it's for

Useful for visually showing a function's behavior (increasing/decreasing regions, roots, intersection points), or for comparing several functions on the same graph.

Source

This is the function-plot library's own options object: official documentation for every supported field (yDomain, grid, annotations, multiple axis sets, etc.): mauriciopoppe.github.io/function-plot. Every field you write in the JSON, other than target/width/height/disableZoom, is passed straight through to the library.

Tsunagi-specific note

Zoom/pan interaction is normally enabled, but it's turned off in the inline (non-fullscreen) view so it doesn't conflict with the page's own scrolling; interaction becomes active once you open fullscreen.