View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
ScrollPlot - scrollable X/Y axes

4.6 | 30 ratings Rate this file 37 Downloads (last 30 days) File Size: 81.7 KB File ID: #14984 Version: 1.7
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 can 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) accordingly.

Both X & Y scrolling are possible.

Custom properties provide access to the scroll axes, central patch and side-bars, for user customizations (e.g., color, patch opacity level, side-bar line-width, etc.).

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 and Zoom Orientation(Axh,State).

MATLAB release MATLAB 6.0 (R12)
MATLAB Search Path
Other requirements Works well on Matlab 6 (R12) and up. Might not work on versions earlier than 6 (untested).
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (47)
30 Jan 2017 Harikrishna Devarajan

With a few modifications, I was able to add the camera pushtool to an existing uitoolbar (created in GUIDE). Excellent submission. Just a small suggestion.

If there were any way to highlight the selected region (instantaneously like the Snipping Tool in Windows), that would be great!

09 Nov 2016 Reinhard Kreuzer

the scrollplot is very helpfull for me, thank you for programming and releasing!

But I have a problem with Matlab 2016b. Scrollplot won't work with datetime in the function 'patch', because datetime is non-numeric. But in version 2016a it works just fine!?
And no, I can't use 2016a, because Matlab is installed by our admin. My colleague has 2016a for some reason, so I was able to test it.

The following script explains my problem.
Is there a way to remove the 'patch' from scrollplot? As far as I saw 'patch' is used to colorize the area between the zoom handles.


%this works:
% x = datenum('01.01.2014 00:00',' HH:MM'):1/(24*4):datenum('31.12.2014 23:45',' HH:MM'); %date and time as number

%but this doesn't work:
x = datenum('01.01.2014 00:00',' HH:MM'):1/(24*4):datenum('31.12.2014 23:45',' HH:MM'); %date and time as number
x = datestr(x); %date and time as string, one character = one value in array
x = datetime(x); %date and time as one value


Thank you and with best regards

07 Jun 2016 Peter newton


Thank you Yair Altman for creating and sharing the ScrollPlot code.

Can someone let me know how to change the position and width of the main plot disply, Y Axis display bar and the X Axis display bar. The Y Axis display bar is very wide and I want to make more use of the display/

I have printed out the scrollplot.m code and its 34 pages long and hard going.

Regards Peter

Comment only
08 Mar 2016 Sebastian Roehn

08 Mar 2016 Sebastian Roehn

I really like this tool and thank you Yair for sharing it, but I have an issue with semilog or loglog plots. I get a warning...

Warning: Negative limits ignored
> In scrollplot>getCenterCoord at 1297
In scrollplot>addScrollPlot at 371
In scrollplot at 163
In scrollplot_test at 9

and when I try to move the x-zoom window it moves directly to a very small or very large value and is stuck than. You can test this issue with this example:

axh = gca;
grid on
grid minor
xlim(axh,[10 10000])

I already tried to compensate a negative limit by using a alternative max:

set(hScroll, limStr, max(0.1, lim + smallDelta*[-1.2,1.2]));

The warning is gone, but the y-zoom window in its scrollbar is not set right and the x-zoom window is still moving directly to a very small or very large value.

Maybe you have an idea what's causing this or a solution for it. Thank you!

Btw...I use R2014b.

Comment only
07 Jan 2016 jon erickson

jon erickson (view profile)

This is a great tool! I use it to scroll vertically to view hundreds of simultaneously sampled signals. One small modification I made was to make the size of the scrollplot window smaller so that the main figure filled more or less maximally filled the figure. Details on my little hack are below.

Two small things I noticed when testing this, might be specific to my application:
1. With several hundred line plot handles in the figure, "grabbing" the blue bars to set the scrollplot window was sometimes difficult to do (not sure why).

2. When I used MATLAB's ginput(...) function to select points on my graphs, the crosshairs caused the underlying graphs to be erased as I moved around the figure. An easy workaround was to download and use MYGINPUT function from the file exchange (

Thanks, Yair, for posting this - extremely useful!

My little hack to make the scrollplot thinner:
Around line 260 to resize the vertical scrollplot to be thinner I did:
newScrollPos = [axPos(1)+axPos(3)*0.98, axPos(2), axPos(3)*0.02, axPos(4)];
newPlotPos = axPos .* [1, 1, 0.975, 1]; %was [1 1 0.80 1]

07 Jul 2015 Fernando Esteves

Thanks Yair, that's just what I was looking for. I never imagined that it could be so simple.
I will comment them.

Comment only
07 Jul 2015 Yair Altman

Yair Altman (view profile)

@Fernando & @Justin - you can use Matlab's builtin linkaxes() function to link various axes, such that if one of them is zoomed or panned (for example, using ScrollPlot), then the other linked axes are also zoomed/panned in the a synchronized manner.

ScrollPlot itself is only attached to a single axes, but using linkaxes() you can make it control multiple axes together.

@Fernando - if you like my books, then please spare a short moment to place a positive feedback comment about them on their Amazon webpage. Thanks.

Comment only
06 Jul 2015 Fernando Esteves

Thanks for sharing Yair :)

All your work, including your blog and books are excellent.

I want to control two axes with the same scroll bar axes. I had spend three entire days trying to do this. Can you help me?

It looks like Justin have the same trouble.

It would be nice if you modified the code to accept all the axes that you want to be affected by the scroll bar.

Thank you.

P.D. Im using Matlab R2015a and works perfect.

Comment only
03 Apr 2015 Justin

Justin (view profile)

Excellent tool, Yair!

@Jim - I am using this with 2014b and it works great. Its strange that the scroll function doesn't seem to work for you.

Yair - I know that another user mentioned that it would be nice to be able to control subplots. Is this a possibility with your function? You have mentioned that it "works on existing plots, within the current boundaries of the axes", but maybe there is a work around?

Thanks for a great submission!

18 Mar 2015 Fernando Esteves

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 1.1

Support for the upcoming HG2

15 Jul 2015 1.6

Fixed warning about obsolete JavaFrame; preserved figure visibility; fixed zoom/pan compatibility

16 Jul 2015 1.7

Fixed custom properties in HG2 (R2014b+); removed reliance on the unsupported setptr function

Contact us