Plot graph not shown

3 views (last 30 days)
Min
Min on 9 Jan 2024
Commented: Min on 10 Jan 2024
Hi, I am currently using 'stackedplot' to plot all of my data (unfortunately I cannot change this to non-stacked plot due to iternative solutions) and due to number of plots, figure can't show all plots.
But I do need to show all the plots somehow.
I tried to use uipanel to adjust the side and made it scrollable but it wasn't still showing all plots.
Is there a way to adjust so that I can scroll to see all plots (variables?)
or alternative way to adjust by deselecting the plots like the 'plot browser'.
Here is the code I use.
figure (1)
penel1 = uipanel('parent',1);
panel2 = uipanel('Parent',penel1);
set(penel1,'Position',[0 0 1 1]);
set(panel2,'Position',[0 -1.8 1 3]);
set(gca,'Parent',panel2);
%figure data info
stackedplot(figure data info); % replace your stack plot fucntion here
s = uicontrol('Style','Slider','Parent',1,...
'Units','normalized','Position',[0.95 0 0.05 1],...
'Value',1,'Callback',{@slider_callback1,panel2});
function slider_callback1(src,eventdata,arg1)
val = get(src,'Value');
set(arg1,'Position',[0 -val 1 2])
end

Answers (1)

Taylor
Taylor on 9 Jan 2024
I would recommend tiledlayout instead. stackedplot seems to be dynamically resizing your plots, tiledlayout does not do this. Of course the individual x-axes are not handled quite as nicely as they are in stackedplot, but you can make those edits yourself (https://www.mathworks.com/help/matlab/ref/matlab.graphics.axis.axes-properties.html).
  3 Comments
Taylor
Taylor on 10 Jan 2024
You won't need the uipanel/uicontrol/slider with tiledlayout because it is not dynamically sized. Play around with nRows in the code below and you'll see that even if you set it to a larger number like 50 all of the plots are still visible in the same window. How legible they are is a different question.
nRows = 15;
data = rand([nRows 10]);
f1 = figure;
tiledlayout(f1, nRows, 1)
for ii = 1:nRows
nexttile
plot(data(ii,:))
end
Min
Min on 10 Jan 2024
Unfortunately, I couldn't find a way to use the tiledlayout for the problem I am seeing (maybe I am not expert enough haha). I tried to create for loop inside for loop since i would need to create multiple plots, figures, with various varibles that are contained in different formats of workspaces.
It got a little complicated sorry.! but thanks for your help! :)

Sign in to comment.

Categories

Find more on Line Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!