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

15 visualizaciones (últimos 30 días)
Sim
Sim el 6 de Mzo. de 2023
Comentada: Les Beckham el 6 de Mzo. de 2023
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 comentarios
Sim
Sim el 6 de Mzo. de 2023
Editada: Sim el 6 de Mzo. de 2023
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 el 6 de Mzo. de 2023
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')

Iniciar sesión para comentar.

Respuesta aceptada

Voss
Voss el 6 de Mzo. de 2023
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 comentarios
Sim
Sim el 6 de Mzo. de 2023
Many thanks @Voss !! :-)
Voss
Voss el 6 de Mzo. de 2023
You're welcome!

Iniciar sesión para comentar.

Más respuestas (1)

Les Beckham
Les Beckham el 6 de Mzo. de 2023
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 comentarios
Sim
Sim el 6 de Mzo. de 2023
Thanks a lot @Les Beckham, very very kind! :-)
Les Beckham
Les Beckham el 6 de Mzo. de 2023
You are quite welcome.

Iniciar sesión para comentar.

Categorías

Más información sobre Interactive Control and Callbacks en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by