MATLAB Combining Plots with Different Y-Axis Ranges in Matlab?

  • Thread starter Thread starter adeeyo
  • Start date Start date
  • Tags Tags
    Matlab Plot
AI Thread Summary
The discussion focuses on how to overlay six different plots in MATLAB, each with varying y-axis ranges. The user seeks guidance on displaying all plots on a single figure despite the differences in y-axis scales. Key suggestions include creating individual axes for each plot and manually positioning them to overlap. The method involves using the 'axes' function to set the position of each plot, with a normalized position vector to control their layout. The user is advised to use the 'hold all' command to plot multiple datasets simultaneously and set a unified axis range using the 'axis' command to accommodate the highest y-value. This approach allows for effective visualization of all plots on one graph.
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
y-axis range is decided only by y-data, not by axes, so they are already independent in that regard.

There are three ways you can put multiple axes on one figure.

1. create each axes and manually place its position on the figure
2. use 'subplot', a built-in MATLAB function
3. use 'subaxis' a open source MATLAB function avaialable on the MATLAB file exchange.
 
Thanks Pythagorean.

Subplot will not work as I want all the plots to overlay on the same plot. Please advise on how to create each axes and manually place its position on the figure.

Thanks

adeeyo
 
axes1 = axes;
set(axes1,'Position',X)

Where X is a four element vector giving (in order): horizontal position of lower left corner, vertical position of lower left corner, width, height.

Units are normalized to the figure (0 to 1), so X=[0 0 1 1] would fill the whole figure.

Now just copy this analogy to make more axes, hand select their positions such that they overlap.
 
if you plot all of the data sets at once, you then can set the axis using the command:
axis([0 1 0 7]); which should work nicely...

Code:
plot (x1,y1);
hold all;
etc...

plot(x6, y6)
hold off;

axis([01 0 7]);
 

Similar threads

Replies
8
Views
2K
Replies
1
Views
4K
Replies
4
Views
2K
Replies
7
Views
2K
Replies
10
Views
3K
Replies
1
Views
2K
Back
Top