Adding a secondary axis to a figure

  • Follow


Hi,

I have concentration values from 6 sources over time, I have plotted these in a single figure as 6 seperate series.  I now also want to add the speed values recorded over time to the same graph.  Completely different data in a different range, the xdata is the same, so I want to add this information using a secondary y-axis on the right hand side of the figure.

I've found the function plotyy, but that seems to only cope with one series to the left and one to the right.  I need 6 to the left and one to the right.

Any help?

Many thanks
0
Reply Jane 9/22/2010 7:16:20 PM

On 10-09-22 02:16 PM, Jane wrote:

> I have concentration values from 6 sources over time, I have plotted
> these in a single figure as 6 seperate series. I now also want to add
> the speed values recorded over time to the same graph. Completely
> different data in a different range, the xdata is the same, so I want to
> add this information using a secondary y-axis on the right hand side of
> the figure.
>
> I've found the function plotyy, but that seems to only cope with one
> series to the left and one to the right. I need 6 to the left and one to
> the right.
>
> Any help?

ax = plotyy(... first of 6 for left..., ... desired right side);
hold(ax(1),'on')
now plot the other 5 specifying ax(1) as the axes to plot in to.


If the 6 sources can be aligned to have common X values, perhaps by padding 
with NaN in places where one of the sources is shorter, then it becomes 
easier: use the 6 different (possibly padded) sources as columns (not rows!) 
of a single matrix, and specify that single matrix as the Y matrix; this will 
draw all 6 at once, allowing you to use a single plotyy() command for both pieces.
0
Reply Walter 9/22/2010 7:31:55 PM


Perfect!!

Thanks :D


> ax = plotyy(... first of 6 for left..., ... desired right side);
> hold(ax(1),'on')
> now plot the other 5 specifying ax(1) as the axes to plot in to.
> 
> 
> If the 6 sources can be aligned to have common X values, perhaps by padding 
> with NaN in places where one of the sources is shorter, then it becomes 
> easier: use the 6 different (possibly padded) sources as columns (not rows!) 
> of a single matrix, and specify that single matrix as the Y matrix; this will 
> draw all 6 at once, allowing you to use a single plotyy() command for both pieces.
0
Reply Jane 9/22/2010 7:50:21 PM

"Jane T" wrote in message <i7dkm4$g4a$1@fred.mathworks.com>...
> Hi,
> 
> I have concentration values from 6 sources over time, I have plotted these in a single figure as 6 seperate series.  I now also want to add the speed values recorded over time to the same graph.  Completely different data in a different range, the xdata is the same, so I want to add this information using a secondary y-axis on the right hand side of the figure.
> 
> I've found the function plotyy, but that seems to only cope with one series to the left and one to the right.  I need 6 to the left and one to the right.
> 
> Any help?
> 
> Many thanks

plotyy(x,[y1;y2;...;y6],x,y7);
0
Reply jimmy.zheng.1982 (1) 1/9/2013 4:23:08 PM

On 1/9/2013 10:23 AM, Jimmy wrote:
> "Jane T" wrote in message <i7dkm4$g4a$1@fred.mathworks.com>...
....

>> I've found the function plotyy, but that seems to only cope with one
>> series to the left and one to the right. I need 6 to the left and one
>> to the right.
>>
....

>
> plotyy(x,[y1;y2;...;y6],x,y7);

And, of course, if the y1 thru y6 aren't of the same length, simply save 
the (two) axes handles using the optional return arguments from plotyy 
and then add directly to the appropriate axis.

Or, one can augment the shorter yn w/ NaN to the longest length and let 
plotyy() deal w/ it automagically since plot() and friends ignore NaN 
silently.

--

0
Reply none1568 (6809) 1/9/2013 9:59:53 PM

4 Replies
578 Views

(page loaded in 0.048 seconds)

Similiar Articles:








7/22/2012 9:40:03 AM


Reply: