Why is one of my subplots being deleted?
26 ビュー (過去 30 日間)
古いコメントを表示
The second subplot is deleted after setting the first, but why? The bottom of the first subplot is at 0.3, whereas the top of the second subplot is at 0.19. There shouldn't be any overlap that would result in deletion.
figure;
ax1 = subplot(2,1,1,'Position', [0.05, 0.3, 0.92, 0.64]);
ax2 = subplot(2,1,2,'Position', [0.05, 0.09, 0.92, 0.1]);
Also, I get the following warning:
Warning: subplot ignores grid location arguments when Position is specified. This syntax will no longer be supported in a future release.
0 件のコメント
採用された回答
Les Beckham
2022 年 2 月 25 日
編集済み: Les Beckham
2022 年 2 月 25 日
If you know the position of the two axes already, you don't need to use the subplot function to position them for you.
Just do this:
figure
ax(1) = axes('position', [0.05, 0.3, 0.92, 0.64]);
ax(2) = axes('position', [0.05, 0.09, 0.92, 0.1]);
Note that I created ax as an array of axis handles.
Now you can plot into those axes.
plot(ax(1), 0:0.01:2*pi, sin(0:0.01:2*pi))
plot(ax(2), 0:10, 0:10)
0 件のコメント
その他の回答 (2 件)
Voss
2022 年 2 月 25 日
The problem: only one axes was created
figure;
ax1 = subplot(2,1,1,'Position', [0.05, 0.3, 0.92, 0.64]);
ax2 = subplot(2,1,2,'Position', [0.05, 0.09, 0.92, 0.1]);
findall(gcf(),'Type','axes')
% (only one axes was created)
A solution: if you are specifying the positions directly, you can use axes() directly to create the axes rather than subplot():
figure;
ax1 = axes('Parent',gcf(),'Units','normalized','Position',[0.05, 0.3, 0.92, 0.64]);
ax2 = axes('Parent',gcf(),'Units','normalized','Position', [0.05, 0.09, 0.92, 0.1]);
findall(gcf(),'Type','axes')
% (two axes were created)
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Subplots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!