How to draw a two y axis and one x axis graph . The Two y axis should arrange in top and bottom and x axis should position in left side of the plot

4 views (last 30 days)
Vishnu
Vishnu on 7 Oct 2014
Edited: Evan on 15 Oct 2014
How to draw a two y axis and one x axis graph . The Two y axis should arrange in top and bottom and x axis should position in left side of the plot
  2 Comments
Vishnu
Vishnu on 15 Oct 2014
Sorry for the delay to reply back. i wants to plot x axis in the vertical position and then plot y axis variable in the horizontal position . Since i have two Y variables to plot, one axis i wants to put on bottom and one axis i wants to put on top, because axis readings are different. Actually i already tried the plotyy command. but i cannot swap the y axis and another major problem i am facing is, i can adjust one of the y axis only. please help me to solve this problem

Sign in to comment.

Answers (1)

Evan
Evan on 15 Oct 2014
Edited: Evan on 15 Oct 2014
If plotyy doesn't work for your purposes, you can create two axes with the same position, then set the 'Color' property of the top axes to 'none' so as to cause it to be transparent. You can then plot one set of data on one axes and one on the other, and change the x and y axis positions to suit your needs. This is quite a bit more messy than plotyy, but I've found it to be a workable solution for cases where I need more control than plotyy can offer.
Here's an example:
figure; a1 = axes; a2 = axes;
plot(1:5,1:5,'-r','Parent',a1)
plot(-2:0.1:2,5*sin(-2:0.1:2),'-g','Parent',a2)
set(a1,'XAxisLocation','top')
set(a2,'Color','none','YTick',[])
uistack(a2,'top')

Community Treasure Hunt

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

Start Hunting!

Translated by