lenend keep only text

22 visualizzazioni (ultimi 30 giorni)
Nikolas Spiliopoulos
Nikolas Spiliopoulos il 5 Nov 2020
Hi all,
I want to put 3 text phrases in a legend wuth red, green, and blue colour respectively (example: 'one' (red), 'two' (green),'three' (blue))
I have seen a similar question here:
I tried to create the first phrase with red using the following commnads:
dummyh = line(nan, nan, 'Linestyle', 'none', 'Marker', 'none', 'Color', 'none');
legend(dummyh,'\color{red}one')
However I cannot add the next 2
could you help me with that?
thanks

Risposta accettata

VBBV
VBBV il 5 Nov 2020
Modificato: VBBV il 5 Nov 2020
dummyh = line(nan, nan, 'Linestyle', 'none', 'Marker', 'none', 'Color', 'none');
dummyv = line(nan, nan, 'Linestyle', 'none', 'Marker', 'none', 'Color', 'none');
dummyz = line(nan, nan, 'Linestyle', 'none', 'Marker', 'none', 'Color', 'none');
legend([dummyh dummyv dummyz],{'\color{red}one','\color{green}two','\color{blue}three'})

Più risposte (1)

Sylvain
Sylvain il 5 Nov 2020
dummyh_1= line(nan, nan, 'Linestyle', 'none', 'Marker', 'none', 'Color', 'none');hold on
dummyh_2= line(nan, nan, 'Linestyle', 'none', 'Marker', 'none', 'Color', 'none');
dummyh_3= line(nan, nan, 'Linestyle', 'none', 'Marker', 'none', 'Color', 'none');
legend([dummyh_1,dummyh_2,dummyh_3], ...
{'One legend entry to rule them all!', 'Yes that s it!','Does it answer your Question?'})
  1 Commento
Sylvain
Sylvain il 5 Nov 2020
Thanks to the answer from @Vasishta, here is an updated verision:
dummyh_1= line(nan, nan, 'Linestyle', 'none', 'Marker', 'none', 'Color', 'none');hold on
dummyh_2= line(nan, nan, 'Linestyle', 'none', 'Marker', 'none', 'Color', 'none');
dummyh_3= line(nan, nan, 'Linestyle', 'none', 'Marker', 'none', 'Color', 'none');
legend([dummyh_1,dummyh_2,dummyh_3], ...
{'\color{red}One legend entry to rule them all!', ...
'\color{green}Yes that s it!',...
'\color{blue}Does it answer your Question?'})

Accedi per commentare.

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by