File Exchange

image thumbnail

ScrollPlot - scrollable X/Y axes

version (81.7 KB) by Yair Altman
ScrollPlot adds a scroll sub-window to any supplied plot handles


Updated 16 Jul 2015

View License

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.

Cite As

Yair Altman (2020). ScrollPlot - scrollable X/Y axes (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (56)

Great function, thank you!
It seems to be dépendent on the figure units -- if I change it to 'Characters' or 'normalized', getCurrentScrollAx will not found an Axes object with current mouse coordinates, so nothing will work. So I have to keep default units (at least with R2018a -- I think before it worked even after units' changing, but I cannot check it).

Sam Wright



Hi everyone I find this extention just perfect!! Although I have a question/problem... I'm using it for a GUI with tabs... if I have a plot on tab A and a plot on tab B both using this extention.... in the same place (plots/axis overlap).
Trying to grab the scroll handles in plot B will not work and they will try to grab the tab A's instead. Hope I made myself clear explaining my problem. How can I solve this??! Thank ou very much for your time.

Rory Uibel

clear all

Awesome. Thank you for providing a nice code.

Very helpful. With little modification, I was able to add horizontal scrolls.

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!

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


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

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.

jon erickson

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]

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

Yair Altman

@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.

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.


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!


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???



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);


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


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 ?




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.


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.


Brilliant, really helpful for long time series.

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?



Yair Altman

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.



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

Thanks a lot*


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!

leo zao

Forgot the rating ...

Yair Altman

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.

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

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 )


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

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

Yair Altman

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.


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:

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?

Nice. One command test of this function.


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!!

K Parsons

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

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?

Felipe raposo

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

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.


Ol Mik

Dadi Gudmundsson

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

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).

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.

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!

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.

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.


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

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

Support for the upcoming HG2

Enabled image exploration per suggestion by Joe Lotz; improved log axis-scaling behavior per suggestion by Fredric Moisy; added scroll visibility & deletion handlers; fixed minor error handling bug

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

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

MATLAB Release Compatibility
Created with R12
Compatible with any release
Platform Compatibility
Windows macOS Linux