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:
plotyy command: is there a way the iser set himself the axes??

Subject: plotyy command: is there a way the iser set himself the axes??

From: Camille Couzi

Date: 22 Oct, 2010 13:06:04

Message: 1 of 3

Hi,
I am trying to plot two variables with shared x-axis and different y values, so I am trying to use plotyy.
I have already defined two axes, ax1 and ax2 (because I am working with a GUI and I plot other things on those axes, not only this data with plotyy).
There is this command in plotyy:
[AX,H1,H2] = plotyy(...) returns the handles of the two axes created in AX and the handles of the graphics objects from each plot in H1 and H2. AX(1) is the left axes and AX(2) is the right axes.

What if I want to tell matlab that the first axe is MY ax1 (and not HIS AX(1)), and the second one is MY ax2 and not HIS AX(2).

I hope my question is clear, any healp would be great, thanks in advance and sorry for my not very good english :-)

Camille.

Subject: plotyy command: is there a way the iser set himself the axes??

From: Steven_Lord

Date: 22 Oct, 2010 13:48:52

Message: 2 of 3



"Camille Couzi" <camillecouzi@yahoo.fr> wrote in message
news:i9s27s$l7o$1@fred.mathworks.com...
> Hi,
> I am trying to plot two variables with shared x-axis and different y
> values, so I am trying to use plotyy.
> I have already defined two axes, ax1 and ax2 (because I am working with a
> GUI and I plot other things on those axes, not only this data with
> plotyy).
> There is this command in plotyy:
> [AX,H1,H2] = plotyy(...) returns the handles of the two axes created in AX
> and the handles of the graphics objects from each plot in H1 and H2. AX(1)
> is the left axes and AX(2) is the right axes.
>
> What if I want to tell matlab that the first axe is MY ax1 (and not HIS
> AX(1)), and the second one is MY ax2 and not HIS AX(2).

You can't do this with PLOTYY. Just use the LINE function to plot your data
on the existing axes instead (or if you've used HOLD, PLOT will also work.)

--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: plotyy command: is there a way the iser set himself the axes??

From: Camille Couzi

Date: 22 Oct, 2010 14:46:04

Message: 3 of 3

Hi steven, thanks for your reply. I have found that page named "Using Multiple X- and Y-Axes", and I am trying to do sthg like the example described there.
=> I have two axes:
h.cp_aux=axes('Parent',h.panel_contourplots);
h.cp_aux2 = axes('parent',h.panel_contourplots,...
    'YAxisLocation','right','Color','none','xtick',[],'YColor','k');

I have thought a little problem, how do I specify the axe wher I want to plot my line?
I have tried with

set(gcf,'CurrentAxes',h.cp_aux);
line(tiempo,vector,'Color','r');

and also with

line(tiempo,vector,'Color','r','parent',h.cp_aux); as in the example,

but nothing to do, matlab always draw the line in the h.cp_aux2, even if I am telling him "plot it in h.cp_aux!!!!
What am I doing wrong?

Thanks again for your answer!

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