Trying to create a scrollable uifigure but unsure how to reference positions
Show older comments
I'm having a hard time understanding how MATLAB handles content that is larger than the size of a figure when the figure's scrollable property is true. Here's a toy example. I'll note from this example it seems that it is not possible to buffer space on the top (only on the bottom). I guess my mental model is something like a canvas size and a viewport, where the latter is smaller than the former. I'll note this is not how I normally think about MATLAB figures, but I'm wondering if it is possible to create this effect. Overall the goal is to support something like a scrollable web page.
Here's the code. Is there a better way of thinking of how scrollable interacts with the figure layout?
fig = uifigure('Position', [100 100 500 800]);
fig.Scrollable = 'on';
canvasWidth = 450;
canvasHeight = 3500; % much taller than visible; scrolling required
% Setting temporarily so that the uiaxes calls make sense.
%
%Does this actually happen? What are the limitations here?
%Should scrolling be enable after rendering/layout?
fig.Position = [1 1 canvasWidth canvasHeight];
% Number of axes
N = 10;
axHeight = 250;
axWidth = 400;
padding = 20;
ax = gobjects(N,1);
% Create axes stacked vertically
for i = 1:N
% Compute vertical position from top down
y = canvasHeight - 400 - i*(axHeight + padding);
ax(i) = uiaxes(fig, ...
'Position', [20, y, axWidth, axHeight]);
plot(ax(i),1:2*i)
title(ax(i), sprintf('Axes %d', i));
end
linkaxes(ax)
fig.Position = [100 100 500 800];
Accepted Answer
More Answers (0)
Categories
Find more on Develop Apps Programmatically 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!