How to bring a patch to the bottom of a figure?

9 ビュー (過去 30 日間)
Sim
Sim 2023 年 3 月 6 日
コメント済み: Les Beckham 2023 年 3 月 6 日
How to bring a patch to the bottom of a figure?
(Maybe with uistack?)
[EDITED] In the following figure, I would like to have the two lines at the top, while the patch at the very bottom of the figure.
hold on
a = plot([1 2 3],[1 2 3],'color','k','LineWidth',3);
b = plot([4 3 2],1:3,'color','r','LineWidth',3);
c = fill([0 4 5 2 1],[0 0 2 4 3],'y');
hold off
  3 件のコメント
Sim
Sim 2023 年 3 月 6 日
編集済み: Sim 2023 年 3 月 6 日
yes, sorry, I edited it... now it is in this way, and I would like to see the two lines at the very top, i.e. with the patch as background...
hold on
a = plot([1 2 3],[1 2 3],'color','k','LineWidth',3);
b = plot([4 3 2],1:3,'color','r','LineWidth',3);
c = fill([0 4 5 2 1],[0 0 2 4 3],'y');
hold off
Sim
Sim 2023 年 3 月 6 日
oh gosh, it was very simple... sorry for this silly question..
hold on
a = plot([1 2 3],[1 2 3],'color','k','LineWidth',3);
b = plot([4 3 2],1:3,'color','r','LineWidth',3);
c = fill([0 4 5 2 1],[0 0 2 4 3],'y');
hold off
uistack(c,'bottom')

サインインしてコメントする。

採用された回答

Voss
Voss 2023 年 3 月 6 日
Option 1: Call fill before plot:
figure()
hold on
c = fill([0 4 5 2 1],[0 0 2 4 3],'y');
a = plot([1 2 3],[1 2 3],'color','k','LineWidth',3);
b = plot([4 3 2],1:3,'color','r','LineWidth',3);
hold off
Option 2: Use uistack(_,'bottom'):
figure()
hold on
a = plot([1 2 3],[1 2 3],'color','k','LineWidth',3);
b = plot([4 3 2],1:3,'color','r','LineWidth',3);
c = fill([0 4 5 2 1],[0 0 2 4 3],'y');
hold off
uistack(c,'bottom')
  2 件のコメント
Sim
Sim 2023 年 3 月 6 日
Many thanks @Voss !! :-)
Voss
Voss 2023 年 3 月 6 日
You're welcome!

サインインしてコメントする。

その他の回答 (1 件)

Les Beckham
Les Beckham 2023 年 3 月 6 日
The code you originally posted already had the lines on top.
Just plot the lines after the patch.
hold on
c = fill([0 4 5 2 1],[0 0 2 4 3],'y');
a = plot([1 2 3],[1 2 3],'color','k','LineWidth',3);
b = plot([4 3 2],1:3,'color','r','LineWidth',3);
hold off
  2 件のコメント
Sim
Sim 2023 年 3 月 6 日
Thanks a lot @Les Beckham, very very kind! :-)
Les Beckham
Les Beckham 2023 年 3 月 6 日
You are quite welcome.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangePolygons についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by