Scatter plot for large data set (tested for 10 million points).


Updated 18 Feb 2014

View License

MATLAB scatter plot function has significant problems showing large data set (e.g. 1000000 points). However, there is no much information in drawing thousands of points one on top of another. scatter_LDS reduces the amount of data shown, while preserving the isolated points.
For example, let's assume that you are conducting a study, which aim is to estimate the probability of myocardial infarction based on two metrics:
- duration of atrial fibrillation during 24 hour ambulatory ECG recording (stored in vector 'holter').
- peak ischemic ST depression during cardiac stress test (stored in vector 'ST').
Also, boolean vector 'MI' has value 'true' for those patients which experience myocardial infarction
during 5 years since the above tests. Use the following commands to initialize the variables:
>> N = 1e6;
>> t = 20*abs(randn(1,N));
>> MI = t<=5;
>> holter = max(0,min(100, 15*randn(1,N)+30+40*5./t));
>> ST = (5-2*MI).*abs(randn(1,N))+5*MI;

Now you can visualise the data using the following commands:
>> scatter_LDS(ST(~MI),holter(~MI));
>> hold on;
>> scatter_LDS(ST(MI),holter(MI),[],'r');
>> hold off

For additional explanations type: help scatter_LDS

This submission is courtesy of Norav Medical ( - the leading company in the fields of PC-ECG, EKG Management systems and related non-invasive cardiac devices.

Cite As

Mark Matusevich (2023). scatter_LDS (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2009b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Find more on Scatter Plots in Help Center and MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes

Screenshot has been lost during the last update. This update returns the screenshot back.

Added the following line to the description: "For additional explanations type: help scatter_LDS"