How to generate and use different colours on a plot and label as per the colours?
古いコメントを表示
Hello all
I want to know how i can generate different colours and use those in my figure and then place on the figure that what colours represents what. My figure will look like the attached image, its only a 3 case example but my final image consits of large number of cases which are variable. In example image I want to add futher the labelling scheme performing like legend,showing colour=abc(pharase) etc.

I hope to get an answer soon
Regards
採用された回答
その他の回答 (2 件)
Mischa Kim
2014 年 5 月 26 日
編集済み: Mischa Kim
2014 年 5 月 26 日
Sameer, something like
x = 0:0.1:1;
y = sin(x);
z = cos(x);
plot(x,y,'r-d',x,z,'b-o',x,y.*z,'g-*')
legend('x vs y','x vs z','x vs y*z')
xlabel('x')
ylabel('y, z, y*z')
3 件のコメント
Sameer
2014 年 5 月 26 日
Mischa Kim
2014 年 5 月 26 日
Check out
data1 = 10*ones(10,2) + randn(10,2); % test data 1: two sets
t1 = (0:1:9);
figure();
p1 = plot(t1,data1,'r-d');
hold on
data2 = 20*ones(100,2) + 2*randn(100,2); % test data 2: two sets
t2 = (0:0.1:9.9);
p2 = plot(t2,data2,'b-o');
data3 = 30*ones(100,2) + 3*randn(100,2); % test data 3: two sets
t3 = (0:0.1:10);
p3 = plot(t2,data3,'g-*');
legend([p1(1),p2(1),p3(1)],'From data1','From data2','From data3');
Sameer
2014 年 5 月 26 日
dpb
2014 年 5 月 27 日
I just had another thought -- don't know if it'll work or not and I cleaned out the trial stuff so don't have it to play w/ at the moment, but:
If you were to use both sets of handles but one with blank text, maybe you could get both symbols one below the other with just the one text line...something like
- a-
- b-
As said, not sure if can get that to happen or not, just a passing fancy of a thought...
ADDENDUM:
Well, I did try it and, by golly, it does work. Not quite what you were looking for ideally, but not too awful bad I'd judge...see what you think w/ this--
[h_leg,h_obj]=legend([p1(:).' p2(:).' p3(:).'],'p0',' ','p1',' ','p2',' ');
カテゴリ
ヘルプ センター および File Exchange で Graphics についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

