Path: news.mathworks.com!not-for-mail
From: "Steven Lord" <slord@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: plotyy&annotating
Date: Sun, 20 Apr 2008 22:57:34 -0400
Organization: The MathWorks, Inc.
Lines: 38
Message-ID: <fugvqu$5hi$1@fred.mathworks.com>
References: <fuc9ie$qp7$1@fred.mathworks.com>
Reply-To: "Steven Lord" <slord@mathworks.com>
NNTP-Posting-Host: lords.dhcp.mathworks.com
X-Trace: fred.mathworks.com 1208746654 5682 144.212.105.187 (21 Apr 2008 02:57:34 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 21 Apr 2008 02:57:34 +0000 (UTC)
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3138
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198
Xref: news.mathworks.com comp.soft-sys.matlab:464218



"Wu Zhiyong" <wuzhiyong_163@163.com> wrote in message 
news:fuc9ie$qp7$1@fred.mathworks.com...
> well,the data are as followed:
> [x,y1],[x,y2],[x,y3];
> I want to plot three lines. plot y1,y2 for the left
> axes,and plot y3 for the right axes.
> It seams that we can just plot 2 lines with the
> function "plotyy".
> I add another "plot",but I failed to annotate the figure.
> my code are as followed:
>
> [Ax,H1,H2]=plotyy(x,y1,x,y3);
> hold on
> H3=plot(x,y2);
> set(gca,'XTick',[0 3 6 9 12 15 18],'XTicklabel',[08 11 14
> 17 20 23 02])
> legend('modis','usgs','diff')
>
> I can't get the right legend and XTicklabel.
>
> Do you have any good ideal?
> any suggestion is appreciated!
> Thanks!

I'd use LINE rather than PLOT in this case:

H3 = line(x, y2, 'Parent', Ax(1))

Then pass in a vector of handles as the first input to LEGEND:

legend([H1, H2, H3], ...)

-- 
Steve Lord
slord@mathworks.com