access to default line colors

조회 수: 20 (최근 30일)
Roy Goodman
Roy Goodman 2017년 7월 27일
답변: Steven Lord 2017년 7월 27일
Is there a way to easily specify a line color from the (relatively) new default line color ordering? What I'd like is to be able to replace the command
>> plot(x,y,'b-o')
with something that gives the new default blue that's different from 'b'.
If not, and I assume not, then let me make this a feature request. Can you make the command
>> plot(x,y,'1-o')
plot a line with the first color in the default ordering, etc?
This would be useful if I plot a line using 'plot(x,y)' and somewhere down the line want to add another line to the plot that is the same color.

답변 (2개)

Steven Lord
Steven Lord 2017년 7월 27일
You can specify the color of a line not only via a LineSpec but also via specifying the line's 'Color' property in the plot call.
ax = axes;
hold on
for k = 1:20
h = plot(1:10, 1:10, '-o', ...
'Color', ax.ColorOrder(ax.ColorOrderIndex, :));
pause(0.5)
end
This will plot a new line 20 times with half a second pause between each plot, each time using the next color in the ColorOrder property of the axes.

Chad Greene
Chad Greene 2017년 7월 27일
You can define any colors col and do
col = jet(5);
set(gca,'colororder',col)
  댓글 수: 3
Roy Goodman
Roy Goodman 2017년 7월 27일
Thanks, but maybe I wasn't clear enough. I know how to use 'linecolor' and to grab the colors from the default ordering as ordered triples. What I would like is a way to use syntax similar simple 'b' for 'blue' specifications with the new colors.
As I said, I think this is most likely not possible, and this question is in practice a feature request.
Chad Greene
Chad Greene 2017년 7월 27일
Oh, I see what you mean. I realize this is not the solution you're seeking, but I think I'd write a new function called myplot that would parse the inputs and then call plot.

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

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by