Which line is on top in a matlab graph?

I am trying to make a simple plot with four sets of data, using different line properties for each data set. For some reason, Matlab seems to plot the lightest colored line on top of the darker lines, and I need to be able to see all of the darkest line, with the lighter lines in the background. Is there any way I can set which line is on top in the plot? Thanks!

 Respuesta aceptada

Walter Roberson
Walter Roberson el 15 de Jun. de 2011

0 votos

For renderers other than OpenGL, the last object drawn should be the one on top, but you can change that order by using uistack()
For OpenGL, lines that are drawn in the same plane do not necessarily have a defined rendering order; the work-around for OpenGL is to use a 3D line and use larger Z values for the lines you want to be on top.

Más respuestas (2)

Paulo Silva
Paulo Silva el 15 de Jun. de 2011
It's the order of the plots, last thing to be added to the axes stays on top, see this example:
clf
hold on
x=0:0.1:10;
plot(x,sin(x),'linewidth',10)
plot(x,cos(x),'r','linewidth',10)
ch=get(gca,'children')
pause(2) %after two seconds the blue line goes to the top
set(gca,'children',[ch(2) ch(1)]) %reorder the children of the axes
Fangjun Jiang
Fangjun Jiang el 15 de Jun. de 2011
I don't think it is the lightness or darkness of the color. It is the order of the plot that matters. Reverse the order of the following code to see the effect.
plot(2:-1:1,'g','linewidth',10);
hold
plot(1:2,'r','linewidth',10);

Categorías

Más información sobre Line Plots en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 15 de Jun. de 2011

Community Treasure Hunt

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

Start Hunting!

Translated by