Combining Plots with Different Y-Axis Ranges in Matlab?

  • Context: MATLAB 
  • Thread starter Thread starter adeeyo
  • Start date Start date
  • Tags Tags
    Matlab Plot
Click For Summary

Discussion Overview

The discussion revolves around the challenge of combining multiple plots with different y-axis ranges into a single plot using MATLAB. Participants explore various methods to achieve this, focusing on overlaying plots rather than using subplots.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant seeks assistance in overlaying six plots with varying y-axis ranges on a single figure.
  • Another participant states that the y-axis range is determined by the y-data, suggesting that axes are independent in that regard.
  • Multiple methods to overlay plots are proposed, including creating individual axes manually, using the 'subplot' function, and employing the 'subaxis' function.
  • A participant expresses that 'subplot' is not suitable for their needs since they want all plots to overlay, requesting guidance on manually positioning axes.
  • A suggestion is made to use the 'axes' function to create overlapping axes by specifying their positions with a vector.
  • Another participant suggests plotting all datasets at once and then setting the axis limits to encompass the maximum y-range needed.

Areas of Agreement / Disagreement

Participants present multiple competing views on how to effectively overlay plots with different y-axis ranges. There is no consensus on a single method, as some prefer manual positioning while others suggest plotting all data at once.

Contextual Notes

Participants do not fully resolve the specifics of how to implement the proposed methods, and there are assumptions about familiarity with MATLAB functions and commands.

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 5 ·
Replies
5
Views
3K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 1 ·
Replies
1
Views
5K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
Replies
5
Views
3K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K