File Exchange

## Scrollsubplot

version 1.2.0.0 (32.5 KB) by
scrollsubplot(n,m,p) p<0 and p>nm, Extends subplot to infinite canvas ...

Updated 03 Feb 2014

Editor's Note: This file was selected as MATLAB Central Pick of the Week

SCROLLSUBPLOT Create axes in tiled positions.

SCOLLSUBPLOT(m,n,p), breaks the Figure window into
an m-by-n matrix of small axes, selects the p-th axes for the current plot, and returns the axis handle. The axes are counted along the top row of the Figure window, then the second row, etc. For example,

SCROLLSUBPLOT(3,1,-1), PLOT(income)
SCROLLSUBPLOT(3,1,1), PLOT(declared_income)
SCROLLSUBPLOT(3,1,2), PLOT(tax)
SCROLLSUBPLOT(3,1,3), PLOT(net_income)
SCROLLSUBPLOT(3,1,4), PLOT(the_little_extra)

plots declared_income on the top third of the window, tax in the middle, and the net_income in the bottom third. Above the top of the figure income is ploted and below the lower edge
the_little_extra is to be found. To navigate there is a slider along the right figure edge.

SCROLLSUBPLOT now also work with less regular subplot-layouts:

axs3(1) = scrollsubplot(3,3,1);
axs3(2) = scrollsubplot(3,3,3);
axs3(3) = scrollsubplot(3,3,[4,7]);
axs3(4) = scrollsubplot(3,3,5);
axs3(5) = scrollsubplot(3,3,[3,6]);
axs3(6) = scrollsubplot(3,3,10);
axs3(7) = scrollsubplot(3,3,[8,9,11,12]);
axs3(8) = scrollsubplot(3,3,[13,14,15);
for i1 = 1:8,
if ishandle(axs3(i1))
axes(axs3(i1))
imagesc(randn(2+3*i1))
end
end

The function works well for regular grids where m,n is constant for all p. When m,n varies there is no guaranti that the steps of the slider is nicely adjusted to the sizes of the subplots.

SCROLLSUBPLOT now also works with mouse-wheel scroll.

Differences with SUBPLOT: SCROLLSUBPLOT requires 3 input arguments, no compatibility with subplot(323), no handle as input. Further PERC_OFFSET_L is decreased from 2*0.09 to 0.07
and PERC_OFFSET_R is decreased from 2*0.045 to 0.085. This leaves less space for titles and labels, but give a plaid grid of subplots even outside the visible figure area.

Bug/feature when the slider is shifted from its initial position and then extra subplots is added, they get mis-positioned.

### Cite As

Bjorn Gustavsson (2021). Scrollsubplot (https://www.mathworks.com/matlabcentral/fileexchange/7730-scrollsubplot), MATLAB Central File Exchange. Retrieved .

yutong wu

Orion Miller

Philipp,

I dont know if this will work for you, but I had the error and was able to get rid of it by changing the second / in the line to a ./

Claire Wilson

This is great!

Is there a way to save the plots/figure window so that the it is still interactive for users which don't have MATLAB?

Brandon Snow

Philipp Bauer

Hello,
unfortuntly i can't use the funktion. I get this error:
-------------------------------------------------------------------------------------------------------------------
Error using /
Matrix dimensions must agree.

Error in scrollsubplot (line 247)
'sliderstep',[1/nrows 1]/(1/((nrows)/max(1,1+maxrownr(:)-minrownr(:)-nrows))))
--------------------------------------------------------------------------------------------------------------------

can anybody help me with this?

many thanks

Philipp

Ashitaka

For error
----------------------------------------------------------------------------------------------------------------
"Operands to the || and && operators must be convertible to logical scalar values."
Error in scrollsubplot (line 235)
if ( nrows*ncols < thisPlot || thisPlot < 1 )

----------------------------------------------------------------------------------------------------------------
Change || to |
line 235
if ( nrows*ncols < thisPlot | thisPlot < 1 )

micholeodon

Hello,

I am using Matlab R2017a. Your toy example does not work:
axs3(1) = scrollsubplot(3,3,1);
axs3(2) = scrollsubplot(3,3,3);
axs3(3) = scrollsubplot(3,3,[4,7]);
axs3(4) = scrollsubplot(3,3,5);
axs3(5) = scrollsubplot(3,3,[3,6]);
axs3(6) = scrollsubplot(3,3,10);
axs3(7) = scrollsubplot(3,3,[8,9,11,12]);
axs3(8) = scrollsubplot(3,3,[13,14,15]);
for i1 = 1:8,
if ishandle(axs3(i1))
axes(axs3(i1))
imagesc(randn(2+3*i1))
end
end

That code produces error in output:
>> axs3(3) = scrollsubplot(3,3,[4,7]);
Operands to the || and && operators must be convertible to logical scalar values.

Error in scrollsubplot (line 235)
if ( nrows*ncols < thisPlot || thisPlot < 1 )

Sven Opgenorth

Very cool and handy tool, but for some reasons i am not able to create scrollable subplots in a uitab.

Gunnar Aronsen

Very usefull

Micah Beckman

Very nice.

hemant

Is it possible to generate an image from this. Using print only prints the current section of the window.

Using scrollsubplot(N,3,i), where N is a constant and i = 1:N in a for-loop, the function resulted in the same plot as if I had used subplot(). That is squeezed plots and no scrolling-bar

Matlab R2016a

Joe

Bjorn, I was wondering if it is possible to put other things inside of the scroll functionality. For example, I have a title I'd like to scroll with some axes. Is this possible?

@ Shai Asher -

If you put scollsubplot in a loop, something like:

for i=1:7
plots2fix{i} = scrollsubplot(3,1,i)
end

Then you have a handle (plots2fix) for each subplot created by scrollsubplot.

Then you can modify the size of each subplot by changing the values of plots2fix{i}.Position. This can be done systematically insdie the loops as well.

Shai Asher

Hi,
i found that if i have a several lines worth of xlabel, the scrolling doesn't account for that and the lower lines are cut off of the figure.
any got any ideas?

Jesse

Operands to the || and && operators must be convertible to logical scalar values.
Error in scrollsubplot (line 235)
if ( nrows*ncols < thisPlot || thisPlot < 1 )

Valerio Biscione

Fantastic, worked without any problem!

Jakob

Hi,

nice tool, could you make it working with asymmetrical subplots like for example scrollsubplot(2,2,[1 3])?

Would be cool

HaveF

Alexander Brodsky

can you add ability of mouse scrolling ?
Thanks for useful feature

David Escot

Perfect!!

Telmo Amaral

This function did precisely what I needed in the easiest possible way: just had to replace all the calls to subplot with calls to scrollsubplot. Particularly liked the fact that page-up/down scroll the defined number of rows, whereas arrow-up/down scroll only one row at a time - very intuitive.

reno renovic

I may be helpfull if you would add a little example how to use this m.file

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