Plotting with different y-axes range in Matlab

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
1 reply · 5K views
adeeyo
Messages
20
Reaction score
0
Good Day Everybody,

Please assist me on these problems

1. I wish to put six plots on the same plot using matlab. The details of each plot are stated below

PLOT 1
x axis range 0:1
y axis range 0:1

PLOT 2
x axis range 0:1
y axis range 0:1

PLOT 3
x axis range 0:1
y axis range 0:1

PLOT 4
x axis range 0:1
y axis range 0:1

PLOT 5
x axis range 0:1
y axis range 0:2

PLOT 6
x axis range 0:1
y axis range 0:7


Please how do I put all these plots on one single plot despite different y-axis range?

Thanks


adeeyo
 
Physics news on Phys.org
Hey adeeyo.

Once you have the arrays of values to be plotted defined, the plot command will automatically resize the window. For example, let's try to put an example PLOT1 and PLOT6 from your list on the same graph:

x1 = 0:0.1:1;
y1 = 0:0.1:1;

x6 = 0:0.1:1;
y6 = 0:0.7:7;

plot(x1,y1,x6,y6)

*make sure your data arrays are the same size!

In general, you can use any number of data pairs in plot: i.e. plot(x1,y1,x2,y2,x2,y3,x4,y4,...) with name/value pair arguments after the data sets to change things like line color or point type: plot(x1,y1,'color','b','*')