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일
1 개 추천
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!
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에서 Color and Styling에 대해 자세히 알아보기
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 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)
