Code covered by the BSD License  

Highlights from
plotLDS

Be the first to rate this file! 3 Downloads (last 30 days) File Size: 9.11 KB File ID: #18857

plotLDS

by Sebastian Hölz

 

20 Feb 2008 (Updated 21 Jan 2009)

Enhance zooming and panning on large data sets by automatically downsampling data

| Watch this File

File Information
Description

DESCRIPTION
===========
Function for plotting large data sets (e.g. time-series with more than 1e6 data points).
The main benefit of this function can be seen in the fact that zooming and paning will work much smoother,
since the data is automatically downsampled to 1e4 points (=> change "n_points" for different number).

USAGE
=====
The usage is exactly identical to the regular plot-command, i.e.:

      plotLDS(x,y,'r')

HINTS & LIMITATIONS
===================

Will only work in Matlab 7.3 or higher.

"DeleteFcn" & "CreateFcn" are used for plotted line and should not be overwritten.
The "ActionPostCallback" (=> zoom & pan) is also used and cannot be used otherwise in the according plots / figures.

Downsampling is simply performed by plotting only every n-th data point. Therefore, aliasing may occur !!!

Data is clipped outside current axislimits and is updated to the current axis-limits after panning / zooming is finished.

Using double-clicking in "zoom-in" modus might not work as expected, because the dispayed data-set
is clipped. It is possible to return to the original data-set by using the scroll-wheel or the "zoom-out" tool.

The x- & y-data is stored as application-data to the plot-handle.

To get the true x- and y-data for the line with handle h, use ...
  x = getappdata(h,'LDS_xdata');
  y = getappdata(h,'LDS_ydata');

EXAMPLES (Use zoom & pan; compare to regular plot-command !!!
========
plotLDS(sin(1e4*(0:1e6)))

phi = linspace(0,2*pi,1e6); plotLDS(sin(x),cos(x),'.')

ax(1) = subplot(2,1,1); plotLDS(rand(1e6,1))
ax(2) = subplot(2,1,2); plotLDS(rand(1e6,1))
linkaxes(ax,'x')

plotLDS(rand(1e6,1)); ax(1)=gca; figure; plotLDS(rand(1e6,1)); linkaxes(ax,'x'); ax(2)=gca; linkaxes(ax,'x')

Acknowledgment
==============
Jiro Doke informed me that his submission "DSPLOT", which was chosen as "Pick of the Week", performs a similar task as this submission. I did not notice before and of course he should be acknowledged.

I did a quick comparison on the two submissions and noticed the following differences:
1) plotLDS is not restriced to single figures / axes but will work for arbitrary combinations. Most important: it will also work for linked axes !!!
2) plotLDS is not restricted to plots with monotonically increasing x-data, but will also handle plots with monotonically increasing y-data and plots with unstructured data (e.g. point-clouds).
3) plotLDS uses exactly the same syntax as the regular "plot"-command. This facilitates the use of this command by simply replacing "plot" by "plotLDS" without having to care for input-arguments.
3) Jiro's submission (DSPLOT) includes a more advanced way of investigating the data to make sure it doesn't miss any "outliers".

MATLAB release MATLAB 7.3 (R2006b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (3)
20 Feb 2008 Jiro Doke

Hi Sebastian,
Just wanted to let you know I also created a similar function:

http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=15850&objectType=file

16 Dec 2011 Hoi Wong

my data has multiple columns (in a matrix), which the regular plot() command or Jiro's dsplot() will draw multiple lines correctly. plotLDS() gave me this error message:

Error in ==> plotLDS at 177
h = plot([min(x) min(x) max(x) max(x)],[min(y) max(y) min(y) max(y)], ...

I'd like to use this feature in subplots, but it seems like Jiro's version doesn't support it.

17 Jan 2012 Sebastian Hölz

Hello Hoi,

as the documentation says ... : "The usage is identical to the regular plot-command for VECTORS ...". So, if you have matrices, you will just have to break them apart and plot each column separately.

Cheers

Sebastian

Please login to add a comment or rating.
Updates
22 Feb 2008

V1.1 (22.02.08): Works for all plotting-syntaxes, monotonically increasing y-data, unstructured data, and for saving and reloading a figure.

V1.0 (20.02.2008): First release

25 Jun 2008

Fixed several bugs.
It is now possible to directly link plotted data to the base workspace: plotLDS(y,'ydatasource','y'). This greatly reduces the memory need.

21 Jan 2009

Revision 33:
- plotLDS now relies on "CallbackStack", which is supplied together with this file.
- New switches.
- Input style for switches changed slightly.
- Bug-fixes.

Tag Activity for this File
Tag Applied By Date/Time
data exploration Sebastian Hölz 22 Oct 2008 09:49:59
plot Sebastian Hölz 22 Oct 2008 09:49:59
large Sebastian Hölz 22 Oct 2008 09:49:59
timeseries Sebastian Hölz 22 Oct 2008 09:49:59
set Sebastian Hölz 22 Oct 2008 09:49:59
data Sebastian Hölz 22 Oct 2008 09:49:59
data exploration Dan K 01 Dec 2008 17:20:35

Contact us at files@mathworks.com