Multi line color in graph
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
0 投票
Hi,
While trying to plot a graph
plot(1:10, rand(10,10))
Each line has a different color.
Is it possible to vary the color scale from a darker shade to lighter shade? For instance, from black to grey
採用された回答
Star Strider
2019 年 11 月 5 日
Try this:
cmap = colormap(gray(10));
figure
hp = plot(1:10, rand(10));
set(gca,'ColorOrder',cmap)
Experiment to get dufferent results.
12 件のコメント
Deepa Maheshvare
2019 年 11 月 5 日
Sorry, it didn't work. I still see multiple colors
Star Strider
2019 年 11 月 5 日
It works correctly for me in R2019b:

It plots only gray lines.
Deepa Maheshvare
2019 年 11 月 6 日
編集済み: Deepa Maheshvare
2019 年 11 月 6 日
Thank you. I am using R2019a. I will upgrade the MATLAB version.
Star Strider
2019 年 11 月 6 日
My pleasure.
My code should work in R2019a.
Deepa Maheshvare
2019 年 11 月 6 日
Unfortunately, I could only obtain this in 2019a

Walter Roberson
2019 年 11 月 6 日
There was a change in r2019b about color order, such that it now affects lines already drawn. In previous versions you need to set the color order before you draw the lines.
Star Strider
2019 年 11 月 6 日
@Walter — I didn’t realise that. Thank you!
Deepa Maheshvare
2019 年 11 月 6 日
cmap = colormap(gray(10));
figure
set(gca,'ColorOrder',cmap)
hp = plot(1:10, rand(10));
I tried the above. It didn't work either.
Could you please suggest what's going wrong?
Star Strider
2019 年 11 月 6 日
I wish I could, since the code I posted works for me. The code appears to be correct, according to the ColorOrder property documentation. (The colororder function is new in R2019b.)
The set call should not be a problem, however the only thing I can think of at this point is to use a slightly different calling syntax:
cmap = colormap(gray(10));
figure
hp = plot(1:10, rand(10));
Ax = gca;
Ax.ColorOrder = cmap;
This also worked when I tried it.
Walter Roberson
2019 年 11 月 6 日
Deepa, do you happen to be using MacOS Catalina ?
Deepa Maheshvare
2019 年 11 月 7 日
Walter, I am uisng Windows OS. I upgraded from 2019a to 2019b. The solution that was posted earlier works fine now. Thank you
Star Strider
2019 年 11 月 7 日
@Deepa Maheshvare — Thank you for following up. I am happy that it worked for you.
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Orange についてさらに検索
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
