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

To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit:

create plot with two different y axis

Asked by Locks on 21 Apr 2013


I have a plot for two different time series which both must be shown in the same figure. the problem is now, that for one dataseries, the y axis should be from 1000 to 1500 and for the other from 20 to 50, how can I do that?




No products are associated with this question.

1 Answer

Answer by Azzi Abdelmalek on 21 Apr 2013
Accepted answer

you can use plotyy function


1 Comment

Locks on 21 Apr 2013

thanks! this is working with the code below:


but there is now another problem, the lines aren't starting at the left axis but there is a space between the left y axis and the line plotted in the graph and the same goes for the right axis.

I tried to use those comands:

% axis([8.5 11.5  0 1500]);
% set(gca,'xtick',9:0.5:11.5) 

but I am not sure how I can use them when I have two differnt axis

Azzi Abdelmalek

Contact us