How to generate and use different colours on a plot and label as per the colours?
53 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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
0 Commenti
Risposta accettata
dpb
il 26 Mag 2014
plot(rand(10,4)) % plot 4 lines in default color cycle
legend('a', 'b', 'c', 'd') % label them -- colors show automagically
text(2,0.05,'Stuff in green','color','g') % add some text in a color
You can create custom colors or select the named colors from a list--there are many examples in the doc. See the doc on the various functions above and the links on annotation and enhancement in the Graphics section.
5 Commenti
Più risposte (2)
Mischa Kim
il 26 Mag 2014
Modificato: Mischa Kim
il 26 Mag 2014
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 Commenti
dpb
il 27 Mag 2014
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',' ');
0 Commenti
Vedere anche
Categorie
Scopri di più su Graphics Object Programming in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!