subplots destroys the axis properties
2 ビュー (過去 30 日間)
古いコメントを表示
Hi all,
I have to create a figure with a specific layout of subplots, but when I call the subplot for the second time all the axis properties are destroyed, why? Here an example:
subhpos(1,:)=[0.0434 0.0339 0.9362 0.9126];
subhpos(2,:)=[0.8189 0.8801 0.1505 0.1017];
figure
set(gcf,'Position',[ 9 49 784 767]);
subh(1)=subplot(1,2,1);
set(subh(1),'Position',subhpos(1,:))
subh(2)=subplot(1,2,2)
set(subh(2),'Position',subhpos(2,:));
subplot(1,2,1)
thanks
cheers
1 件のコメント
採用された回答
dpb
2014 年 7 月 10 日
Per the doc, if you overwrite the area of a subplot, it deletes the existing one and creates a new one. AFAIK there's no way to avoid this behavior. There's an example of an overlaying axes with subplot() in the documentation; note that it avoids this by specifying that axes with axes, not another subplot.
You can probably get by with yours if you only refer to the two axes with the saved handles once they're created.
0 件のコメント
その他の回答 (1 件)
Joseph Cheng
2014 年 7 月 10 日
well what you can try is this by moving the setting of the axis properties at the end such that you do not overwrite them.
figure
subhpos(1,:)=[0.0434 0.0339 0.9362 0.9126];
subhpos(2,:)=[0.8189 0.8801 0.1505 0.1017];
x=[60:20:260]; %set x axis ticks
y=rand(11); %get something to plot
subh(1)=subplot(2,1,2); %setup subplot1
plot(x,y,'-.'); %plot subplot1
xlim([60 260]) %setup some x axis
set(gcf,'Position',[ 9 49 784 767]);
y2 = 10*y.^2; %make something up for subplot2
subh(2)=subplot(2,1,1); %make subplot2
plot(x,10*y,'-.'); %plot subplot2
xlim([60 260]) %setup some x axis
set(subh(2),'Position',subhpos(2,:))
set(subh(1),'Position',subhpos(1,:));
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!