define a color for plot

23 ビュー (過去 30 日間)
alpedhuez
alpedhuez 2018 年 6 月 8 日
回答済み: Image Analyst 2018 年 6 月 8 日
I create a plot such as
Plot1=plot(Date,A,'Color',[0.1112456 0.2098437 0.31116789],'LineWidth',1.2)
Now I want to define a customized color beforehand so that I do not need to type
'Color',[0.1112456 0.2098437 0.31116789]
each time. Please advise.

採用された回答

Walter Roberson
Walter Roberson 2018 年 6 月 8 日
There is no facility to create additional color names.
There are some ways you can proceed:
  1. create a function or a variable mycolor that stores [0.1112456 0.2098437 0.31116789] and code 'Color', mycolor each time
  2. create a DefaultLineColor property at the level of the object you want to use this color by default, such as set(gcf, 'DefaultLineColor', [0.1112456 0.2098437 0.31116789]) . You might have difficulty when you have multiple plots on the same axes.
  3. Change the axes ColorOrder property to an N x 3 array of RGB values; the first line object in the axes will use the first row by default, the second will use the second row, and so on, with it going back to the beginning again if you draw enough lines
  2 件のコメント
alpedhuez
alpedhuez 2018 年 6 月 8 日
編集済み: Walter Roberson 2018 年 6 月 8 日
Walter Roberson
Walter Roberson 2018 年 6 月 8 日
The struct and containers.Map options suggested in that post fall into the same category as my first option: you still have to 'Color' and designate the color each time you plot. My second and third suggestions are ways to avoid needing to specify the color each time, so that
Plot1=plot(Date, A, 'LineWidth', 1.2)
could still end up using [0.1112456 0.2098437 0.31116789]

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

その他の回答 (1 件)

Image Analyst
Image Analyst 2018 年 6 月 8 日
Regarding changing the default color order, see my attached demo.

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by