Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
736 views
in Technique[技术] by (71.8m points)

matlab - Second subplot disappearing

I have a weird (and probably simple to solve) problem. I tried to plot (using panel) two plots:

a1 = subplot(2,1,1, 'Parent', handles.cpd_plot, 'Position', [0.1, 0.4, 0.85, 0.45]);
a2 = subplot(2,1,2, 'Parent', handles.cpd_plot, 'Position', [0.1, 0.1, 0.85, 0.15]);

but after plotting a2, a1 disappears. I see that its some problem with position, when I lift up a1 a bit ('Position', [0.1, 0.5, 0.85, 0.45]) its working (but it has to be >= 0.5). Where is the problem? Thanks!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

So it is probably happening because subplot deletes a plot when it is overlapping with the previous plot. I suspect that happens because of conflicting positions values between the subplot tile number (i.e. subplot(2,1,1) etc) that has its own default position, and the position you entered.

So instead of using subplot(m,l,p, 'position', [ a b c d]), you can solve this issue by using subplot just with the position info as follows:

subplot('position',  [0.1, 0.4, 0.85, 0.45])
plot(1:10);
subplot('position', [0.1, 0.1, 0.85, 0.15])
plot(1:10);

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...