Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
MATLAB legends

Subject: MATLAB legends

From: Osama Husain

Date: 9 Feb, 2009 11:02:01

Message: 1 of 6

Hi all, i m stuck in a situation that i would like to share in this forum. I have generated a figure in MATLAB having multiple curves. Legends of this curve were shown through the GUI "insert legend" button. Now i want to hide some of the legends while showing the others. Anyone help will be appreciated.

Regards...

Subject: MATLAB legends

From: Husam Aldahiyat

Date: 9 Feb, 2009 12:58:02

Message: 2 of 6

"Osama Husain" <omhr81@yahoo.com> wrote in message <gmp2f9$aj2$1@fred.mathworks.com>...
> Hi all, i m stuck in a situation that i would like to share in this forum. I have generated a figure in MATLAB having multiple curves. Legends of this curve were shown through the GUI "insert legend" button. Now i want to hide some of the legends while showing the others. Anyone help will be appreciated.
>
> Regards...

Insert a legend in the code itself.

LEGEND(H,string1,string2,string3, ...)

where H is the handle(s) of the plots and the strings correspond to the handles.

for example;

t=0:.1:4
y=cos(t)

hold on
h1=plot(t,y,'r')
h2=plot(t,y.*2,'g')
h3=plot(t,y./2,'b')

legend([h1,h3],'cos','cos/2')

Subject: MATLAB legends

From: Joerg Buchholz

Date: 9 Feb, 2009 13:04:01

Message: 3 of 6

"Osama Husain" <omhr81@yahoo.com> wrote in message <gmp2f9$aj2$1@fred.mathworks.com>...
> Hi all, i m stuck in a situation that i would like to share in this forum. I have generated a figure in MATLAB having multiple curves. Legends of this curve were shown through the GUI "insert legend" button. Now i want to hide some of the legends while showing the others. Anyone help will be appreciated.
>
> Regards...

plot (rand (5,5))
legend show
leg = findobj (gcf, 'tag', 'legend')
set (leg, 'String', {'data1' 'data4' 'data5'})

Subject: MATLAB legends

From: Osama Husain

Date: 11 Feb, 2009 11:20:02

Message: 4 of 6

"Husam Aldahiyat" <numandina@gmail.com> wrote in message <gmp98p$kfm$1@fred.mathworks.com>...
> "Osama Husain" <omhr81@yahoo.com> wrote in message <gmp2f9$aj2$1@fred.mathworks.com>...
> > Hi all, i m stuck in a situation that i would like to share in this forum. I have generated a figure in MATLAB having multiple curves. Legends of this curve were shown through the GUI "insert legend" button. Now i want to hide some of the legends while showing the others. Anyone help will be appreciated.
> >
> > Regards...
>
> Insert a legend in the code itself.
>
> LEGEND(H,string1,string2,string3, ...)
>
> where H is the handle(s) of the plots and the strings correspond to the handles.
>
> for example;
>
> t=0:.1:4
> y=cos(t)
>
> hold on
> h1=plot(t,y,'r')
> h2=plot(t,y.*2,'g')
> h3=plot(t,y./2,'b')
>
> legend([h1,h3],'cos','cos/2')


The issue is that i have already generated the figures and it requires 4 to 5 hrs to generate them. On top of that, i don't have the values or reading of the generated figures, so what possible method can i follow which can be applicable on the figure itself?

Subject: MATLAB legends

From: Joerg Buchholz

Date: 11 Feb, 2009 14:06:02

Message: 5 of 6

"Osama Husain" <omhr81@yahoo.com> wrote in message
:
> The issue is that i have already generated the figures and it requires 4 to 5 hrs to generate them. On top of that, i don't have the values or reading of the generated figures, so what possible method can i follow which can be applicable on the figure itself?

Osama, which line of

plot (rand (5,5))
legend show
leg = findobj (gcf, 'tag', 'legend')
set (leg, 'String', {'data1' 'data4' 'data5'})

don't you understand?

Joerg

Subject: MATLAB legends

From: Osama Husain

Date: 12 Feb, 2009 13:54:01

Message: 6 of 6

"Joerg Buchholz" <buchholz@hs-bremen.de> wrote in message <gmum0a$64p$1@fred.mathworks.com>...
> "Osama Husain" <omhr81@yahoo.com> wrote in message
> :
> > The issue is that i have already generated the figures and it requires 4 to 5 hrs to generate them. On top of that, i don't have the values or reading of the generated figures, so what possible method can i follow which can be applicable on the figure itself?
>
> Osama, which line of
>
> plot (rand (5,5))
> legend show
> leg = findobj (gcf, 'tag', 'legend')
> set (leg, 'String', {'data1' 'data4' 'data5'})
>
> don't you understand?
>
> Joerg

At this moment, "None" :-)
Thanks Joerg, i got it now...

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us