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!

 채택된 답변

Walter Roberson
Walter Roberson 2011년 6월 15일

0 개 추천

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.

추가 답변 (2개)

Paulo Silva
Paulo Silva 2011년 6월 15일

1 개 추천

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 2011년 6월 15일

0 개 추천

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);

카테고리

도움말 센터File Exchange에서 Line Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by