Code covered by the BSD License  

Highlights from
ScrollPlot - scrollable X/Y axes

4.88
4.9 | 26 ratings Rate this file 66 Downloads (last 30 days) File Size: 81.7 KB File ID: #14984 Version: 1.7
image thumbnail

ScrollPlot - scrollable X/Y axes

by

Yair Altman (view profile)

 

14 May 2007 (Updated )

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

| Watch this File

File Information
Description

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.

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

Examples:
   >> 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.

Warning:
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.

Acknowledgements

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)
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 (41)
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???

Thanks!

27 Oct 2014 Mindaugas

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

Thanks!

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

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

Hi,
when i use this stuff, with graphics.cursobar mentioned on the undocumented mat site
e.g. with this code:
fgMain=figure('Tag','fgMain');
bitstream=bytes(:,1:5000);
[count,data]=packagesync(bitstream,'d391',1,10e-6);
setappdata(fgMain,'data',data);
a=cell2mat({data.start});
hp=plot(a,0,'--rs');
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)
scrollplot(hp);
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?

Thanks

Fabian

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.

Yair

Comment only
25 Jan 2010 Marcos Afonso

Hello,

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

Thanks a lot*

Marcos

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

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

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

Nice.
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 http://www.mathworks.com/support/contact_us/dev/javaframe.html )

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:
scrollplot(plot([-10:0.01:10]',sin([-10:0.01:10]')),'axis','xy');
scrollplot(plot([-10:0.01:10]',sin([-10:0.01:10]')),'axis','xy');
scrollplot(plot([-10:0.01:10]',sin([-10:0.01:10]')),'axis','xy');
scrollplot(plot([-10:0.01:10]',sin([-10:0.01:10]')),'axis','xy');
scrollplot(plot([-10:0.01:10]',sin([-10:0.01:10]')),'axis','xy');
scrollplot(plot([-10:0.01:10]',sin([-10:0.01:10]')),'axis','xy');

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.
scrollplot(plot([-10:0.01:10]',sin([-10:0.01:10]')),'axis','xy','minx',5,'miny',0.5);

29 Jan 2009 puru

puru (view profile)

This is really an excellent utility..!!
Yair,

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,
x=0:10;
y=0:10;
plot(x,y);

and it works fine.

But when I tried following different codes,
1.scrollplot(plot(x,y));
2.scrollplot(handles.axes1,plot(x,y));
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!!
~puru

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

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.

Thanks,
Santosh.

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

Great!
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.
us

Updates
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