subplots destroys the axis properties
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaire
Réponse acceptée
dpb
le 10 Juil 2014
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 commentaires
Plus de réponses (1)
Joseph Cheng
le 10 Juil 2014
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 commentaires
Voir également
Catégories
En savoir plus sur Subplots dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!