Info

この質問は閉じられています。 編集または回答するには再度開いてください。

how shalll I swith to different Axes in one figure?

1 回表示 (過去 30 日間)
vx2008
vx2008 2016 年 8 月 10 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
figure;
H1=axes;
plot(x1,y1);(after that insert its legend on the figure)
H2=axes;
plot(x2,y2);(after that insert its legend on the figure)
H3=axes;
plot(x1,y1);(after that insert its legend on the figure)
After that I set "color" of "H2" and "H3" to be 'none';
Now I can see the three "lines" together and I want to rearrange the three "legends" (I find I just can move legend3) and add x-axis lable for H2 (I find I can't insert x-label for H2). How shall I?

回答 (1 件)

Walter Roberson
Walter Roberson 2016 年 8 月 10 日
You cannot legend() all of the entries individually to get a combined legend. You need to legend() at the end. Better yet would be to record the handles of each of the plots and pass the array of those handles as the first entry to legend(). Also, each of those axes() calls is causing everything before that to be erased because you are not using "hold on". You should consider using subplot()
fig = figure;
H1 = subplot(1, 3, 1, 'Parent', fig);
L(1) = plot(H1, x1, y1, 'r');
H2 = subplot(1, 3, 2, 'Parent', fig);
L(2) = plot(H2, x2, y2, 'b');
H3 = subplot(1, 3, 3, 'Parent', fig);
L(3) = plot(H3, x1, y1, 'g');
legend(L, {'first plot', 'second plot', 'third plot'})
  1 件のコメント
vx2008
vx2008 2016 年 8 月 10 日
Thank you very much. I have resolve this problem according to your explanation.

この質問は閉じられています。

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by