Combining Plots with Different Y-Axis Ranges in Matlab?

  • MATLAB
  • Thread starter adeeyo
  • Start date
  • Tags
    Matlab Plot
In summary, to put six plots on the same plot in MATLAB with different y-axis ranges, there are three options: manually placing each axis on the figure, using the 'subplot' function, or using the 'subaxis' function. To manually place each axis, the 'axes' and 'set' functions can be used and the axes can be positioned using a four element vector. Another option is to plot all the data sets at once and then use the 'axis' function to set the desired axis range.
  • #1
adeeyo
20
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
  • #2
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.
 
  • #3
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
 
  • #4
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.
 
  • #5
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]);
 

1. What is a double y-axis plot in Matlab?

A double y-axis plot in Matlab refers to a graph that has two y-axes, one on the left and one on the right, with the same x-axis. This allows for the visualization of two different sets of data on the same graph, making it easier to compare and analyze the relationship between the two variables.

2. How do I create a double y-axis plot in Matlab?

To create a double y-axis plot in Matlab, you can use the "yyaxis" function. This function allows you to specify which data to plot on the left and right y-axes. You can also customize the appearance of the axes, such as changing the scale or adding labels.

3. Can I add more than two y-axes in a Matlab plot?

No, Matlab only supports the creation of a double y-axis plot. However, you can use the "yyaxis" function multiple times to plot more than two sets of data on the same graph.

4. How do I change the scale of the y-axes in a double y-axis plot?

You can use the "yyaxis" function with the "ylim" property to change the scale of each y-axis. This allows you to adjust the range of values shown on the y-axes to better visualize your data.

5. Can I customize the appearance of each y-axis separately in a double y-axis plot?

Yes, with the "yyaxis" function, you can specify which y-axis you want to customize by using the "left" or "right" argument. This allows you to change the color, font, and other properties of each y-axis independently.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
883
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
7
Views
964
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
10
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
718
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
995
Back
Top