How can I plot two vectors using the plotyy command, and after that plot two points with different y-scales on the same graph?

3 views (last 30 days)
  • Graphing:
I have three vectors, Ia (current), Va (voltage), Pa (power).
First I want to plot "Ia vs Va" and "Pa vs Va" on the same graph, given that Ia and Pa have two different y-scales. (Ia: ylim([ 0 10], Pa: ylim([0 300]))
This can be done using the plotyy command without any problems.
But then I would like to plot the ordered pairs (Va(mpp), Ia(mpp),'bo') and (Va(mpp), Pa(mpp), 'go') on the same graph. So how can I specify that I want to plot the first pair one according to the left y-axis scale and the second one to the right y-axis?
Thank you very much!
Eid

Answers (2)

Sean de Wolski
Sean de Wolski on 14 Dec 2012
You can continue to add axes with no color and whose 'layer' is 'bottom' in the same position as the two axes created by plotyy().
Whenever I've had to do this, I start by creating a simple plotyy plot and then breaking the axes down using get:
[ax,h1,h2] = plotyy(1:10,1:10,1:10,100:-10:1);
Then compare:
get(ax(1))
with
get(ax(2))
To figure out what settings are doing what.

José-Luis
José-Luis on 14 Dec 2012
Edited: José-Luis on 14 Dec 2012
[AX,H1,H2] = plotyy(Va,la,Va,Pa); %handles to the axes will be in AX
plot(AX(1),Va(mpp), Ia(mpp),'bo');
plot(AX(2),Va(mpp), Pa(mpp), 'go')

Categories

Find more on Two y-axis in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!