Hi,
I have about 17 variables to plot in one graph. I don't want to use the standard eight colors again and again. Is there any way by which we can plot using different colors? I tried plotting using RGB:: Color but everytime I do that I get a syntax error. Could you please help me with it? Thanks .

답변 (1개)

Geoff Hayes
Geoff Hayes 2017년 2월 23일

1 개 추천

kanyvt - the colour can be represented by a 1x3 array where all components are between zero and one. (The first for Red, the second for Green, and the third for Blue.) You can then specify which colour to use as
>> x = -2*pi:0.001:2*pi;
>> y = sin(x);
>> plot(x,y,'Color',[0 1 0]);
>> hold on;
>> plot(x,y+1,'Color',[0 1 1]);

댓글 수: 5

kanyvt
kanyvt 2017년 2월 23일
Thanks for your response. But how can I specify a different color like grey or orange ? Is there any way to find the numbers associated with these colors?
Yes, just use any search engine with the keywords orange RGB colour code and you should be presented with the RGB (decimal) code. Take those value (which are most likely in the range of 0 and 255) and create an array of those values (like above) and make sure that you divide each by 255. For example, querying for orange shows me that its RGB code is (255,165,0). Create the orange colour array as
orangeRGB = [255,165,0]./255;
and use that in your call to (say) plot.
kanyvt
kanyvt 2017년 2월 23일
Yes, that helped. Thank you :)
Steven Lord
Steven Lord 2017년 2월 23일
There's also a small UI named uisetcolor that you can use to identify the numeric values associated with a particular color.
I believe there are also some File Exchange submissions that are somewhat related to this task, one that comes to mind right away is John D'Errico's fuzzycolor. I know that's inspired a couple other submissions as well.
kanyvt
kanyvt 2017년 2월 27일
Thanks for your answer

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

질문:

2017년 2월 23일

댓글:

2017년 2월 27일

Community Treasure Hunt

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

Start Hunting!

Translated by