Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: 3 Y axes wih 4 variable
Replies: 9   Last Post: Apr 24, 2013 9:28 AM

 Messages: [ Previous | Next ]
 dpb Posts: 9,850 Registered: 6/7/07
Re: 3 Y axes wih 4 variable
Posted: Apr 20, 2013 10:06 AM

On 4/20/2013 2:24 AM, Murat wrote:
> Hi. I am new in Matlab and i have a problem having plotting 3 'Y' axes
> with one of the Y axes are common with two variable. it's like 4
> variable as in the image. How can i get the true code? Please help me out.
> http://img401.imageshack.us/img401/1750/3yaxeswith2common.png

See doc under 'Graphics -- Objects -- Axes Properties' there's a topic
titled "Using Multiple X= and Y-Axes"

From its example modified slightly...

x1 = [0:.1:40];
y1 = 4.*cos(x1)./(x1+2);
x2 = [1:.2:20];
y2 = x2.^2./x2.^3;

>> hl1 = line(x1,y1,'Color','r');
ax1 = gca;
set(ax1,'XColor','r','YColor','r')

pos_ax1 = get(ax1,'Position'); % get the position vector 1st axis
% set the left position for another; make width so right sides match...
pos_ax2=pos_ax1; pos_ax2(1)=0.25;
pos_ax2(3)=pos_ax1(3)+pos_ax1(1)-pos_ax2(1);
ax2 = axes('Position',pos_ax2,...
'XAxisLocation','bottom',...
'YAxisLocation','left',...
'Color','none',...
'XColor','k','YColor','k');

Salt to suit...

--

Date Subject Author
4/20/13 Murat
4/20/13 dpb
4/21/13 Murat
4/23/13 Murat
4/23/13 Murat
4/23/13 dpb
4/23/13 Murat
4/24/13 dpb
4/24/13 Murat
4/24/13 dpb