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!
"Wu Zhiyong" <wuzhiyong_163@163.com> wrote in message
<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!
>
"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:
> 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
I don't see why people should have to put up with so
cryptic an interface as plotyy. One shouldn't have to
mess with all these handles to do something so basic
as to plot 3 lines with a legend.
I've developed an alternative interface (called plt)
for this type of thing. For instance the above would be:
The 'Right' parameter tells plt to put the 3rd trace
on the right hand axis. (You still would need the
set gca command however to get the unusual x-axis ticks.)
Of course, there are many more options in plt for making
the plot appear as you prefer - see plt.chm to see what
they are. (Note: available from the file exchange).
Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for
all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content.
Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available
via MATLAB Central. Read the complete Disclaimer prior to use.