Graph Plotter
Plot one-variable real functions directly in the browser. Use this lightweight plotter to sample functions, inspect behavior (zeros, maxima/minima, asymptotes), and export sampled (x,y) data as CSV. Enter multiple functions separated by semicolons to compare curves.
Plotting functions in the browser: sampling, visualization and interpretation
Visualizing mathematical functions is one of the fastest ways to build intuition. A plot reveals behavior that algebra alone can hide: oscillations, asymptotes, sharp transitions and flat regions. This Graph Plotter is designed to be a pragmatic, browser-based tool for exploring single-variable real functions. It samples the function at regular intervals, maps sampled values to pixel coordinates, and renders curves and optional sample points. While not a full-featured plotting library, it is ideal for teaching, quick checks, and preparing data for higher-fidelity plotting tools.
Sampling: the heart of plotting
All client-side plotters rely on sampling: evaluating f(x) at a finite set of x values within the chosen domain. The sampling density (number of samples) controls resolution — too few samples can miss features like narrow spikes or rapid oscillations; too many samples increase computation time and can overload the browser. For most smooth functions, a few hundred samples produce a clean curve on standard display sizes; functions with rapid variation need denser sampling or adaptive strategies.
Uniform vs adaptive sampling
Uniform sampling (equally spaced x) is simple and predictable. It works well for many problems, but suffers when the function contains localized features: narrow peaks, boundary layers, or discontinuities. Adaptive sampling increases sample density where the function changes rapidly — for instance by measuring curvature or difference between linear interpolants and refining intervals where the error is large. Adaptive schemes are more complex but can give accurate plots with fewer total samples. This plotter uses uniform sampling for simplicity and speed, but exporting the sampled data makes it easy to feed into adaptive routines offline.
Handling discontinuities and asymptotes
Discontinuities (jumps) and vertical asymptotes (where |f(x)|→∞) often produce misleading lines that connect points across the break. A robust renderer should detect large jumps between consecutive samples and break the polyline to avoid drawing connecting segments that don't represent the function. In our implementation the renderer treats non-finite outputs (NaN, ±Infinity) as gaps and does not connect across them. Increasing sampling density near suspected singularities helps locate asymptotes more accurately for analysis.
Y-range selection and autoscaling
Choosing the y-range is crucial for readable plots. Automatic y-range estimation (from sampled finite values) is convenient, but extreme outliers can dominate and squash interesting structure. The plotter offers an auto mode which trims a small fraction of extreme values before selecting min/max (e.g., ignore the top and bottom 1% samples) to avoid a few spikes controlling the whole scale. Manual y-range control is available when you want a fixed scale across multiple plots for comparison.
Smoothing, anti-aliasing and perceptual considerations
Plot smoothness can be improved by simple line interpolation between sample points. For very noisy or discrete data, smoothing filters (moving average, low-pass) help readability but distort high-frequency content. Anti-aliasing is handled by the canvas renderer and modern browsers; for publication-quality figures vector backends (SVG or PDF) and higher-precision libraries are preferred.
Multiple functions and color coding
The plotter supports multiple comma- or semicolon-separated functions. Each function is sampled independently and drawn with a distinct color. When comparing functions, keep consistent line styles and scales to make differences clear. Colorblind-friendly palettes and line patterns (dash styles) are recommended for accessibility — consider exporting data and plotting in a library that supports advanced styling if needed.
Performance and browser limits
Modern browsers handle thousands of simple numeric evaluations quickly, but expensive operations (transcendental functions, heavy per-sample processing) or extremely dense sampling (tens of thousands of points) can slow rendering and block the UI. Use moderate sample counts for interactive exploration, and export data to perform heavy plotting server-side or with WebGL-accelerated libraries when needed.
Export and reproducibility
The tool lets you export sampled (x,y) pairs as CSV, enabling reproduction of plots and further analysis in desktop tools (Python, R, Excel). For reproducible figures record the function expression, x-range, sample count, and any y-range trimming. This page includes Copy and Download CSV functions to capture these parameters alongside the sampled values.
Use cases
- Quickly inspect functions before applying numerical methods (root finding, integration).
- Teach and demonstrate mathematical concepts: periodicity, convergence, and asymptotics.
- Generate sample data for offline analysis or publication plots.
Limitations and next steps
This browser plotter is intentionally lightweight. For advanced needs consider: adaptive sampling, WebGL rendering for massive point sets, interactive tooltips, export to SVG/PDF for vector-quality figures, and integration with plotting libraries like Plotly or Chart.js for polished interactivity. Still, for many tasks this tool provides fast, informative visual feedback directly in your browser.
Use the controls above to adjust domain, sample density, toggles for grid and points, and export the sampled values. If you need an expanded feature set (multi-dimensional plots, parameter sweeps, or Fourier/FFT views) tell me which direction you prefer and I can extend this page.
Frequently Asked Questions
Use JavaScript Math syntax: Math.sin(x), Math.exp(-x*x), x*x + 2*x - 1. Separate multiple functions with semicolons.
NaN or infinite outputs indicate domain issues (e.g., sqrt of negative number). The plot skips those points and leaves a gap rather than drawing a false connection.
Either reduce y-range extremes or increase the sample count. For very high-frequency functions use a higher sampling density.
Yes — enter multiple expressions separated by semicolons and the plot will draw each in a different color.
Sampled values are computed using JavaScript doubles (IEEE-754). They are accurate for visualization and many numerical checks, but not a substitute for high-precision arithmetic libraries when needed.
Basic zoom uses mouse wheel (when focused on canvas) and pan by dragging — these controls are implemented with simple linear transforms; for more advanced zooming consider a plotting library.
Spikes can result from sampling near asymptotes or functions with large derivatives. Try narrowing the domain or increasing sampling density near the spike.
Click 'Download CSV' after plotting to save sampled (x,y) pairs for each function. CSV includes headers and the function expressions used.
The UI is responsive but interactive canvas controls are best on desktop. On mobile, reduce sample counts for performance.
Yes — AkCalculators provides this tool for free as part of its educational calculator suite.