Shortcut to default line colors?

96 ビュー (過去 30 日間)
Roy Goodman
Roy Goodman 2020 年 7 月 30 日
コメント済み: Walter Roberson 2020 年 7 月 31 日
I can't remember how long ago MATLAB switched to the new default line color order. Overall, I much prefer the new colors. I'll never go back to the old [0,0,1] blue. However I'd like to be able to use the old shortcut and get the new blue.
plot(x,y,'b-o')
Is there a way for me to redefine the blue produced by this code to be the new default line color?
What I'd most like is for MathWorks to define a new shortcuts '1'-'7' to produce the seven colors in the default sequence, but I would be somewhat satsified if I could hack things so that the old abbreviations give me the new colors.
I know I can do things like
plot(x,y,'color,',[0 0.447 0.741])
to get the new blue, and I have even written little one-line codes that will prevent me from having to memorize this value. However, I often write demos for my undergrads, The old way makes shorter easier codes, but produces graphs that use the bad-looking old color schemes.

回答 (1 件)

Walter Roberson
Walter Roberson 2020 年 7 月 30 日
編集済み: Walter Roberson 2020 年 7 月 30 日
cmap = colororder();
returns the current axes color order in a form that is the same as a color map. So you could then do things like
plot(x, y, 'color,', cmap(1,:))
  2 件のコメント
Roy Goodman
Roy Goodman 2020 年 7 月 31 日
Thanks. That's somewhat helpful but it's still a lot of characters. Any extra line in an demonstration program I write for undergrads is a place they can get tripped up.
Walter Roberson
Walter Roberson 2020 年 7 月 31 日
To be explicit then:
There is no way to redefine the colors produced by the letter codes. There are multiple internal locations that have the color values hardcoded for the color names and letters.
What can be changed is the default color order that is produced when multiple lines are plotted without specifying a color.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeGrid Lines, Tick Values, and Labels についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by