Run it in your browser

Playground

Run six real TypePlot examples, explore the view and save data charts to PNG.

Sine and cosine
Auto
Preparing the plot…Real TypePlot, running in this browser.

Drag to pan or orbit. Scroll to zoom. Focus the plot for arrow keys, +/− and Home. PNG export is available for data examples.

Sine and cosine sampled at 200 points from 0 to 2π. Both amplitudes range from −1 to 1.

Code for this plotmain.ts
import { subplots, linspace } from "typeplot";

const { fig, axes: [ax] } = subplots();
const x = linspace(0, 2 * Math.PI, 200);
ax.plot(x, x => Math.sin(x * 1), { label: "Sine" });
ax.plot(x, x => Math.cos(x * 1), { label: "Cosine", lineStyle: "--" });
ax.set({ xLabel: "Angle (radians)", yLabel: "Amplitude" });
ax.grid();
ax.legend();

// Call fig.destroy() when the view unmounts.

Runtime source: 7444877e0037 · Apache-2.0

About the example data

Values come from the formulas and fixed arrays in the sample code. They are illustrative data, not measurements or benchmarks. Visitor-provided source is never evaluated.