How can i use both the left and right y axis on a single figure?
    2 views (last 30 days)
  
       Show older comments
    
Hi. Av been trying to have multiple plots on a single graph using both the left and the right y axis but i can.t. Av even tried using the yyaxis command but it gives me an error. please what do I do?
0 Comments
Answers (3)
  Steven Lord
    
      
 on 1 Jun 2016
        The yyaxis function was introduced in release R2016a as indicated by the comment at the bottom of its documentation page. If you're using an older release take a look at the plotyy function and use hold on one or both of the axes then call plot with the appropriate axis handle as the first input argument to add a plot parented to the specified axes.
  Elias Gule
      
 on 1 Jun 2016
        try the plotyy command. In the command window type
doc plotyy
to see examples of how to use the function.
  Elias Gule
      
 on 2 Jun 2016
        Ok, try this:
 x = linspace(0,2*pi,100);
 y1 = 2*cos(x);
 y2 = -2*sin(x);
 y3 = 5*sin(2*x);
 y4 = -10.5*sin(5*x);
 [hAx,hLine1,hLine2] = plotyy([x' x' x'],[y1' y2' y3'],x,y4);
 axis tight
0 Comments
See Also
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!

