Change colors' short names or add new ones

19 ビュー (過去 30 日間)
Rostislav Teryaev
Rostislav Teryaev 2019 年 2 月 16 日
回答済み: Image Analyst 2019 年 2 月 17 日
MatLab has eight short names for colors, which are: r, g, b, c, m, y, k, w. I want to add new short names for my own colors. Does anyone know how to do it?
I suppose that it is not possible by standart matlab functionality, but I am aware about "Undocumented Secrets of Matlab-Java Programming" book by Yair Altman, and maybe there is someone who is enough proffesional in it?
I know about workarounds, but I need only exactly what I want :)
  1 件のコメント
Star Strider
Star Strider 2019 年 2 月 16 日
You can ask Yair Altman (link) yourself!
He was here on MATLAB Answers a few hours ago.
Be sure to post back here with his reply to your inquiry.

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

採用された回答

Walter Roberson
Walter Roberson 2019 年 2 月 17 日
No. They are hardcoded into function colstyle for validation purposes. On OS-X that is part of libmwhgbuiltins.dylib

その他の回答 (1 件)

Image Analyst
Image Analyst 2019 年 2 月 17 日
It's trivial.
You can add the code to your startup.m file or your specific m-file. For example to create dark versions of 'r', 'g', and 'b', you can do
darkRed = [0.5, 0, 0];
darkGreen = [0, 0.5, 0];
darkBlue = [0, 0, 0.5];
% Plot something in dark green
plot(1:10, '-*', 'Color', darkGreen);
Note that you have to use the 'Color' option rather than just using it in the linestyle specification. You can define any color with any name you like by specifying any 3 number vector with values between 0 and 1.

カテゴリ

Help Center および File ExchangeEnvironment and Settings についてさらに検索

タグ

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by