필터 지우기
필터 지우기

Where in the axes properties (or elsewhere) is the "pointer" on the next color of ColorOrder ?

조회 수: 2 (최근 30일)
The command
hold all
holds the current line color in the ColorOrder, so that following plot commands continue cycling through it. This seems to be only a feature of high-level-functions like plot. However, there must be a change in the 'axes properties' (besides the 'NextPlot' property), something like a pointer telling the next plot, which color to be used.
My problem is that I use low-level-function 'line' and want to add another line(s) in the next color of ColorOrder. Is there a more simple way to realize this instead of getting the existing line objects color by some functions as get,findobj and then choosing a non-used color for current line, which could not really considered as cycling.
Thanks.
  댓글 수: 2
José-Luis
José-Luis 2013년 1월 12일
You could create your own custom order and cycle through it.
Alexander
Alexander 2013년 1월 12일
편집: Alexander 2013년 1월 12일
thanks, but I do not want another ColorOrder. I just want to know where is the axes property, which calls a next plot whether to cycle in that order or reset to the first entry.
In other words: How MATLAB realizes, that 'hold on' reset the ColorOrder and 'hold all' not. And where I can find these difference.

댓글을 달려면 로그인하십시오.

채택된 답변

José-Luis
José-Luis 2013년 1월 12일
편집: José-Luis 2013년 1월 12일
Maybe not exactly what you wanted but a workaround:
fH = figure;
aH = axes;
lH = plot(rand(10,1),'r');
your_colors = get(fH,'DefaultAxesColorOrder');
colorIdx = find(ismember(your_colors,get(lH,'Color'),'rows'));
nextColorIdx = mod(colorIdx + 1, size(your_colors,1));
nextColor = your_colors(nextColorIdx,:);
I think creating your own custom color order and cycling through it would be better. The snippet I gave you will not work if the color of the line you plot is not in the default colors.
  댓글 수: 1
Alexander
Alexander 2013년 1월 12일
Thanks for this code, Jose-Luis. But if I would use plot (instead of line) I also could realize a cycling through the ColorOrder with hold all .
I just thought that there must be a pointer somewhere in the properties which color have to be the next (if hold all was entered). This pointer, or whatever, could then be used for the next line command. (instead of additional code)
But thanks.

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Walter Roberson
Walter Roberson 2013년 1월 12일
getappdata(gca, 'PlotColorIndex')
When it is non-empty, it is the index of the next color to plot.
  댓글 수: 2
Alexander
Alexander 2013년 1월 12일
편집: Alexander 2013년 1월 12일
I checked this for plot and line. For plot it works, it shows the next index, but in the case of 'line' the result is an empty matrix.
Seems to be a low-level/high-level-function feature (?)
Walter Roberson
Walter Roberson 2013년 1월 12일
If I recall correctly, line() does not cause cycling through the color order; it is functionality built into plot()

댓글을 달려면 로그인하십시오.


Alexander
Alexander 2013년 1월 12일
Seems to be that when using line instead of plot the only way to realize the automatic cycling through colors is the way Jose-Luis has suggested.
Thanks Walter for your answer too.

카테고리

Help CenterFile Exchange에서 Graphics Object Properties에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by