Thread Subject:
How to add title to legend of a graph?

Subject: How to add title to legend of a graph?

From: Karl Trumstedt

Date: 7 Aug, 2007 10:40:23

Message: 1 of 3

Hi all,

I am trying to add a title to my graph's legend, is this
possible? I have tried a few alternatives and it seems like
this is not supported, the easiest way seems to add a
textlabel at the top of the legend and pin it to the graph.
I figured that I should make a try asking here just in case.

Subject: How to add title to legend of a graph?

From: Rick Rosson

Date: 7 Aug, 2007 11:26:11

Message: 2 of 3

Hi Karl,

Yes, it is possible to add a title to a legend, using Handle Graphics:

   f = figure;
   a = axes;
   hold on;

   p(1) = plot(t,X,'color','b');
   p(2) = plot(t,Y,'color','r');
   ...
   ...

   h = legend('X','Y');
   v = get(h,'title');
   set(v,'string','Legend Title');


I hope that helps. Thanks.

Rick





"Karl Trumstedt" <karltru@gmail.com> wrote in message
news:f99i6n$9l7$1@fred.mathworks.com...
> Hi all,
>
> I am trying to add a title to my graph's legend, is this
> possible? I have tried a few alternatives and it seems like
> this is not supported, the easiest way seems to add a
> textlabel at the top of the legend and pin it to the graph.
> I figured that I should make a try asking here just in case.
>

Subject: How to add title to legend of a graph?

From: Karl Trumstedt

Date: 7 Aug, 2007 11:34:03

Message: 3 of 3

Worked like a charm, thanks a lot

"Rick Rosson" <rrosson@mathworks.com> wrote in message
<f99ksl$qbh$1@fred.mathworks.com>...
> Hi Karl,
>
> Yes, it is possible to add a title to a legend, using
Handle Graphics:
>
> f = figure;
> a = axes;
> hold on;
>
> p(1) = plot(t,X,'color','b');
> p(2) = plot(t,Y,'color','r');
> ...
> ...
>
> h = legend('X','Y');
> v = get(h,'title');
> set(v,'string','Legend Title');
>
>
> I hope that helps. Thanks.
>
> Rick
>
>
>
>
>
> "Karl Trumstedt" <karltru@gmail.com> wrote in message
> news:f99i6n$9l7$1@fred.mathworks.com...
> > Hi all,
> >
> > I am trying to add a title to my graph's legend, is this
> > possible? I have tried a few alternatives and it seems
like
> > this is not supported, the easiest way seems to add a
> > textlabel at the top of the legend and pin it to the
graph.
> > I figured that I should make a try asking here just in
case.
> >
>
>

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

Tag Activity for This Thread
Tag Applied By Date/Time
legend Karl Trumstedt 7 Aug, 2007 06:45:03
rssFeed for this Thread

Contact us