Within a plot, how can I create an inset containing multiple subplots using subtightplot?
古いコメントを表示
If I use the built-in suplot function, it works:
% Main plot
x = linspace(0, 10, 100);
plot(x, sin(x), 'LineWidth', 1.5);
xlabel('X'); ylabel('Y');
% Inset made of subplots
hp = uipanel('Parent', gcf, 'Position', [0.6 0.6 0.3 0.3]);
for i = 1:4
ax = subplot(2, 2, i, 'Parent', hp);
plot(ax, x, sin(i*x), 'r');
end
% Main plot
x = linspace(0, 10, 100);
plot(x, sin(x), 'LineWidth', 1.5);
xlabel('X'); ylabel('Y');
% Inset made of subplots
hp = uipanel('Parent', gcf, 'Position', [0.6 0.6 0.3 0.3]);
subplot = @(m,n,p) subtightplot(m, n, p, [0.05 0.05], [0.05 0.05], [0.05 0.05]);
for i = 1:4
ax = subplot(2, 2, i);
ax.Parent = hp;
plot(ax, x, sin(i*x), 'r');
end
回答 (1 件)
Star Strider
約13時間 前
1 投票
You need to download the subtightplot.m function to your MATLAB path.
2 件のコメント
Star Strider
約9時間 前
You probably need to check to be certain that your code is essentially the same as that in subtightplot_demo.m .
Also, rather that starting off with uipanel, see if you can get it to work natively, for example similar to the demo code.
Another consideration is that the subtightplot code was last modified in 2013. The convention known as 'Handle Graphics 2' (HG2) was adopted in 2016, and there have been other modifications since. It may simply not work correctly with all the changes to MATLAB graphics in the intervening 13 years.
It might be best for you to use either subplot (that works, as you noted), or tiledlayout instead, that could give you the tight grouping you appear to want.
カテゴリ
ヘルプ センター および File Exchange で Subplots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


