Figure inside a figure in uifigure environment
13 views (last 30 days)
Show older comments
I would like to show a figure inside a figure to zoom in on some details. Here ( https://de.mathworks.com/matlabcentral/answers/60376-how-to-make-an-inset-of-matlab-figure-inside-the-figure ) I found an approach, that would fit my needs, but I would like to create the figure in the uifigure environment. And I fail to do this with an uifigure.
So below is the code for the unzoomed figure and for the smaller figure I would like to show the last n values of the lines in the left upper corner. In another script I created the smaller figure already, but how can I import this figure from the workspace to include this in this complete figure? Or is there an easier way?
line1 = out1.variableX.signals.values
line2 = out2.variableX.signals.values
line3 = out3.variableX.signals.values
line0 = out0.variableX.signals.values
time = linspace(0,10,length(line0))
f = uifigure;
ax = axes(f);
plot(ax, time, line0, time, line1, time, line2, time, line3, LineWidth=3)
ylim(ax, [0,60])
ax.YTick = [0 10 20 30 40 50 60]
0 Comments
Answers (1)
Voss
on 10 Sep 2023
You'll create two axes inside one figure, not two separate figures.
Something along these lines, to get started:
f = uifigure;
ax = axes(f);
plot(ax, time, line0, time, line1, time, line2, time, line3, LineWidth=3)
ylim(ax, [0,60])
ax.YTick = [0 10 20 30 40 50 60];
% determine where the inset axes goes:
inset_width = 0.3; % normalized units
inset_height = 0.3;
pos = ax.Position;
inset_pos = [pos(1) pos(2)+pos(4)-inset_height inset_width inset_height];
% create the inset axes:
ax_inset = axes(f,'Position',ax_inset_pos);
% plot something into it:
plot(ax_inset,time(end-n+1:end),line0(end-n+1:end));
See Also
Categories
Find more on Visualization and Data Export 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!