Editor's Note: This file was selected as MATLAB Central Pick of the Week
This simple tool intercepts data going into a plot and reduces it to the smallest possible set that looks identical given the number of pixels available on the screen. It then updates the data as a user zooms or pans. This is useful when a user must plot a very large amount of data and explore it visually.
This works with MATLAB's built-in line plot functions, allowing the functionality of those to be preserved.
Instead of:
plot(t, x);
One could use:
reduce_plot(t, x);
Most plot options, such as multiple series and line properties, can be passed in too, such that 'reduce_plot' is largely a drop-in replacement for 'plot'.
h = reduce_plot(t, x(1, :), 'b:', t, x(2, :), t, x(3, :), 'r--*');
This function works on plots where the "x" data is always increasing, which is the most common, such as for time series.
For more information, see:
>> help LinePlotReducer
or
>> help reduce_plot
Cite As
Tucker McClure (2022). Plot (Big) (https://github.com/tuckermcclure/matlab-plot-big), GitHub. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxCategories
- MATLAB > Graphics > 2-D and 3-D Plots > Line Plots >
Tags
Acknowledgements
Inspired: daniel-frisch-kit/plot-ecg, matfig2pgfdata(filename,m,n), JimHokanson/plotBig_Matlab, detectEcgWithAngle(ecg, fSInHz, varargin): Heartbeat detection using sample-to-sample angle, matlab2dplot2datafile
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.