Code covered by the BSD License  

Highlights from
ScrollPlot - scrollable X/Y axes

4.9 | 24 ratings Rate this file 56 Downloads (last 30 days) File Size: 15.3 KB File ID: #14984
image thumbnail

ScrollPlot - scrollable X/Y axes


Yair Altman (view profile)


14 May 2007 (Updated )

ScrollPlot adds a scroll sub-window to any supplied plot handles.

| Watch this File

File Information

ScrollPlot adds a scroll sub-window to any supplied plot handles (or current [gca] axes if no handle was supplied). This enables easy plot or image exploration.

The user may specify initial view window parameters or use the defaults.

Dragging the side-bars or central patch modifies the parent axes limits interactively. Conversely, modifying the parent axes limits (with zoom, pan or programatically) modifies the corresponding scroll patch(es).

Both X & Y scrolling are possible.

Scrollplot works ok with log and reverse axes. ScrollPlot works on Matlab 6 (R12) and up.

scrollHandles = scrollplot(plotHandles, propName,propValue,...)

>> scrollplot; % add scroll sub-window to the current axes (gca)
>> scrollplot(plot(xdata,ydata), 'WindowSize',50); % plot with initial zoom
>> scrollplot('Min',20, 'windowsize',70); % add x-scroll to current axes
>> scrollplot([h1,h2], 'axis','xy'); % scroll both X&Y of 2 plot axes
>> scrollplot('axis','xy', 'minx',20, 'miny',10); % separate scroll minima

See extensive help within.

This code relies in [small] part on undocumented and unsupported Matlab functionality. It works on Matlab 6+, but use at your own risk!

Bugs and suggestions:
Please send to Yair Altman (altmany at gmail dot com)

Change log:
See the bottom of this webpage

This ScrollPlot was inspired by Steve Lord's scrollplot demo submission, but is an entirely new implementation with lots of new functionality.


Scrolling Plot Demo inspired this file.

This file inspired Ui Split Pane Split A Container (Figure/Frame/Uipanel) Into Two Resizable Sub Containers.

MATLAB release MATLAB 6.0 (R12)
Other requirements Works on Matlab 6+. Might not work on versions earlier than 6.
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (36)
21 Jan 2015 Jim

Jim (view profile)

Scrolling doesn't work with 2014b. It works great with 2014a and both 2013 releases. This is a very useful control - hoping for an update that works with 2014b???


27 Oct 2014 Mindaugas

But it not worked in GUIDE, because in 1087 line

cp = get(hFig, 'CurrentPoint'); % in Matlab pixels

coordinates may not be in pixels. So you can make workaround:

old_unit=get(hFig, 'Units');
set(hFig, 'Units','pixels');
cp = get(hFig, 'CurrentPoint'); % in Matlab pixels
set(hFig, 'Units',old_unit);

11 Aug 2014 Vincent

In Windows Matlab R2014a I get a similar problem after a while:

Warning: Setting the "WindowButtonUpFcn" property is not permitted while this mode
is active.
> In uitools.uimodemanager.uimodemanager>localModeWarn at 83
In uitools.uimodemanager.uimodemanager>@(obj,evd)(localModeWarn(obj,evd,hThis)) at 63
In scrollplot>mouseWithinPatch at 731
In scrollplot>mouseMoveCallback at 920

Comment only
01 Aug 2014 svdevprof

Excelent tool Yair!

I'm testing it in Matlab 2013a for MacOsx. The scroll bar works good as long as I do not zoom in the graph. If I zoom in, and then zoom out and then try to drag and drop left or right the scrollbar slider, it gets stuck and I get the following message:

Warning: Setting the "WindowButtonUpFcn" property is not permitted while this mode is active.
> In uitools.uimodemanager.uimodemanager>localModeWarn at 83
In uitools.uimodemanager.uimodemanager>@(obj,evd)(localModeWarn(obj,evd,hThis)) at 63
In scrollplot>mouseWithinPatch at 735
In scrollplot>mouseMoveCallback at 924

After this the scrollbar is not usable (does not move when trying to drag it) and i have to close figure and plot it again. Does anyone have the same issue ?


01 Aug 2014 svdevprof  
24 Jul 2014 Warwick

Great. The grey overview within the slider strip is very useful for long time series. I used it to identify instrument gremlins in anemometers. Given that wind is inherently variable, it was almost impossible otherwise.

03 Mar 2014 Harsimrat

Great tool. I am wanting to use it to scroll the video frames. The frames scroll needs linking to to another time series plot which I can do using (linkaxes) but I need to get the values of the scroll axes every time I scroll the time series plot to feed the video frame scroll.

Comment only
07 Jan 2014 Eoghan

Eoghan (view profile)

Brilliant, really helpful for long time series.

10 Dec 2013 Marko Budisic  
11 Oct 2010 Fabian H.

when i use this stuff, with graphics.cursobar mentioned on the undocumented mat site
e.g. with this code:
hCursorbar = graphics.cursorbar(hp); drawnow
hCursorbar.CursorLineColor = [.9,.3,.6]; % default=[0,0,0]='k'
hCursorbar.CursorLineStyle = '-.'; % default='-'
hCursorbar.CursorLineWidth = 2.5; % default=1
hCursorbar.Orientation = 'vertical'; % =default
hCursorbar.TargetMarkerSize = 12; % default=8
hCursorbar.TargetMarkerStyle = 'o'; % default='s' (square)
I´ll get the expected GUI, but in the Tooltip of the graphics.cursobar is no 'String' shown.
I´am sure there is one in, i can see him in the property inspector, but not in the GUI.
Before line 326 in scrollplot I´am able to see the 'String'. After the Line only the Tooltip is shown.

Has anybody got an idea to solve this problem?



25 Jan 2010 Yair Altman

Yair Altman (view profile)

Marcos - it works for me and countless other users... So email me a specific code example that does not work and tell me exactly what does not work and all the relevant info (your Matlab version/platform etc.), otherwise I'm afraid I cannot help you much.


Comment only
25 Jan 2010 Marcos Afonso


I've the same problem that the user "puru" have...
can you help me with that ?

Thanks a lot*


Comment only
25 Jan 2010 Marcos Afonso  
11 Oct 2009 leo zao

Thanks a lot for this really nice and useful function!
I tried it with a time series and unfortunately the axes of the scrollplot part don't seem to "react" to the function "datetick". (It labels the tick lines of an axis using dates, replacing the default numeric labels)
I am a beginner with matlab and if someone know how to deal using dates with the function scrollplot, I would be very grateful!
Thanks a lot!

Comment only
11 Oct 2009 leo zao  
17 Sep 2009 almog shalom

Forgot the rating ...

11 Sep 2009 Yair Altman

Yair Altman (view profile)

Almog - The warnings can be eliminated by typing:

warning off MATLAB:HandleGraphics:ObsoletedProperty:JavaFrame

I'll add it to a new version when I get to it, but in the meantime you can simply add this to your startup.m file or your Matlab Command Window. It has no negative effect.

אשמח אם תוכל להקדיש רגע להזין רייטינג :-)

Comment only
09 Sep 2009 almog shalom

One comment:
When I try it, MATLAB prouce the following warning:

Warning: figure JavaFrame property will be obsoleted in a future release. For more information see
the JavaFrame resource on the MathWorks Web site.

(with a link to )

Comment only
28 Aug 2009 Tim

Tim (view profile)

A version that would link scrolling across subplots would be very cool.

08 Jun 2009 joe saucer

Yair, i have a string of data and i want to look at it very close up.. and also want to scroll, but because of the close up specifications, i cant scroll because i cant get the mid blue pane

Comment only
14 May 2009 Yair Altman

Yair Altman (view profile)

Rene - ScrollPlot is not a replacement for the plot function - it works on existing plots, within the current boundaries of the axes, so of course the new axes gets smaller to leave room for the scrollbars. This is exactly how it is supposed to work.

If you want to update the plot data, don't call plot again and again - instead, update the data of the plot handle.

Next time, make sure to read the documentation and understand the usage before you post a review... Others might say RTFM, but I say that considering that this minor issue made you think ScrollPlot only merits a mediocre rating, means that you have an exceptionally developed sense of quality perfection. I therefore look forward to learning from your would-be superior submissions here on the File Exchange.

Comment only
14 May 2009 Rene

Rene (view profile)

very nice.
but if i plot some data, it looks fine
if i wanna plot new data, the axis the smaller and smaller by each time i type the plot command
just try this:

14 May 2009 Ward Jennekens

Very nice utility! One question: when I remove a plot point with the 'selectdata' tool, the scrollbar will not function actively any more, only passively follow zoom alterations. Is there any way to (re)set focus to the scrollbar again?

20 Feb 2009 Lukas Lansky

Nice. One command test of this function.

29 Jan 2009 puru

puru (view profile)

This is really an excellent utility..!!

One question. How can I include this utility in the GUI programming?

I simply had a GUI template which has,
1) Axis component
2)pushbutton component

I tried following code in the pushbutton callback,

and it works fine.

But when I tried following different codes,
3.scrollplot(handles.axes1,plot(x,y),'axis','xy', 'minx',0,'maxx',10, 'miny',0,'maxy',10);
4.scrollplot(plot(x,y),'axis','xy', 'minx',0,'maxx',10, 'miny',0,'maxy',10);

none of them worked...!! It just shows those scrolling bars but does not work. I want to use this excellent utility in my GUI - will you plese suggest me how can I use it?

Versions I tried,
1.Matlab6.1 R12.1
2.Matlab7 R7007a

Thank you in Advance!!

Comment only
10 Sep 2008 K Parsons

Excellent. However, this gives a warning with Matlab 2008b -- Warning: figure JavaFrame property will be obsoleted in a future release.

13 Aug 2008 Sellavelu Sathyapriya

I have a gui with two axes. For one axes, I want to use the scrollplot. I tried using it, but it is not scrolling. At the same time when I tried to plot the graph, using 'figure' and then use scrollplot, it works. Why it doesn't work in the gui? Do I have to modify axes settings? Can you help?

09 Jul 2008 Felipe raposo

does anyone tryed to use ScrollPlot with datetickzoom / tlabel ? it bugs..

08 Jul 2008 Santosh Kandregula

Hello Yair,
Your Scrollplot m-file is really great. i t helped me a lot.
But when I am trying to throw the figure into GUI, the scrollable thing doesn't work.
Can you please help as how this can be made, so that it can work in GUI.


07 Jun 2007 Ol Mik  
30 May 2007 Dadi Gudmundsson

Very useful for the exploration of large plots. Highly recommended.

16 May 2007 Yair Altman

The corrected version is now available for download. A new version will be posted in a few days with support for Fredric Moisy's suggestions (improved log-scaling behavior & automatic parent axes resizing on scroll axes deletion/hiding).

Comment only
16 May 2007 Yair Altman

A new version has just been posted with fixes per John D'Errico's comments (thanks). However, I found out yesterday that this second version had a few bugs so I immediately posted a third version with fixes. I suggest that users wait for this new version (titled 2007-05-15), and NOT download the 2007-05-14 version. I hope the new version will be up in a few hours or by tomorrow. Sorry for the mixup.

Comment only
16 May 2007 F Moisy

I give 4.99 stars to this submission. I would
happily raise up to 5.00 stars with the following minor improvements:
- Use the same symbols in the subwindow than in the window.
- when calling twice "scrollplot", it adds a (probably unwanted) "sub-sub-window".
- it behaves strangely with log scale.
- add a "scrollplot off" option to remove the subwindow.

Many thanks!

14 May 2007 John D'Errico

A very nice tool in all respects. Well done.

I did notice that when I tried to add both an x and a y scrollbar, I had to be careful. Since the first call adds a second set of axes, if you are not careful, the second scrollbar may be attached to the set of axes created for the first scrollbar. This is easy to deal with of course.

I also wondered why an allowable option for the 'axis' property was not 'xy'. This would resolve the minor issue that I tripped over.

14 May 2007 urs (us) schwarz

an excellent help section and a great, compatibility-aware engine, which is neatly arranged by subfunctions and comes with copious error check-points as well as interesting use of many try-catch blocks, make this application a must-have for people in need of visual data exploration.
could be a ML stock function...
very well done.

16 May 2007

Set focus on parent axes after scroll-axes creation; added special scroll props; allowed 'Axis'='xy'

16 May 2007

Added 'MinX' etc. params; clarified error msgs; fixed 'xy' bugs; added 'ParentAxesHandle' special prop

27 Jun 2013

Support for the upcoming HG2

Contact us