Using Scrollbars in Matlab when trying to view a large number of plots

22 visualizaciones (últimos 30 días)
I am trying to use a scrollbar to slide through a large number of plots. I have combined the following:
with other code in order to do so, but regardless of what I do I cannot seem to change the size of 'panel2'. i.e., in this example I am trying to plot 20 graphs, but it will only show 10 before they end up outside of the where the slider can move to, and none of the 'Position' sets seem to help with this at all.
figPos = [200 200 800 1000];
figure('Color', 'w', 'Position', figPos)
panel1 = uipanel('Parent',2);
panel2 = uipanel('Parent',panel1);
set(panel1, 'Position',[0 0 0.95 1]);
set(panel2,'Position',[0 -1 1 20]);
s = uicontrol('Style','Slider','Parent',2,...
'Units','normalized','Position',[0.95 0 0.05 1],...
'Value',1,'Callback',{@slider_callback1,panel2});
leftPadding = .0625; % the space at the left of the figure
horizPadding = .1; % the space between axes (horizontally)
bottomPadding = .05; % the space at the bottom of the figure
vertPadding = .1; % the space between axes (vertically)
nHorizAxes = 2;
nVertAxes = 20;
width = .35;
height = .1;
x = linspace(0, 2*pi);
y = sin(x);
for iRow = 1:nVertAxes
for iCol = 1:nHorizAxes
% calculate the position
left = leftPadding+(iCol-1)*(width+horizPadding);
bottom = bottomPadding+(iRow-1)*(height+vertPadding);
position = [left bottom width height];
%myAxes(iRow, iCol) = axes('Position', position);
ax = axes(panel2,'Position', position);
plot(x, y, 'b', 'Parent', ax)
xlabel('Percentage Target Load (%)')
ylabel('Percentage Target Strain (%)')
title(sprintf('axes(%d, %d)', iRow, iCol))
end
end
function slider_callback1(src,eventdata,arg1)
val = get(src,'Value');
set(arg1,'Position',[0 -val 1 2])
end
I was forced to place the plots within axes(). As apparently you cannot plot directly into a uipanel. Not sure if that is part of the issue? And if so what the workaround might be?

Respuestas (0)

Categorías

Más información sobre Annotations en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2016b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by