Double y-axis plot in Matlab


by adeeyo
Tags: plotting matlab
adeeyo
adeeyo is offline
#1
Dec23-12, 12:19 AM
P: 19
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

Best regards,
adeeyo
Phys.Org News Partner Science news on Phys.org
Internet co-creator Cerf debunks 'myth' that US runs it
Astronomical forensics uncover planetary disks in Hubble archive
Solar-powered two-seat Sunseeker airplane has progress report
Pythagorean
Pythagorean is offline
#2
Dec23-12, 01:58 AM
PF Gold
Pythagorean's Avatar
P: 4,214
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.
adeeyo
adeeyo is offline
#3
Dec24-12, 10:22 PM
P: 19
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

Pythagorean
Pythagorean is offline
#4
Dec24-12, 10:30 PM
PF Gold
Pythagorean's Avatar
P: 4,214

Double y-axis plot in Matlab


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.
Dr Transport
Dr Transport is offline
#5
Dec25-12, 03:53 PM
Sci Advisor
PF Gold
P: 1,458
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....

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

plot(x6, y6)
hold off;

axis([01 0 7]);


Register to reply

Related Discussions
Python, matplotlib plot 2D histogram on polar axis. Math & Science Software 4
How to plot multiple iterations of a while loop on one plot? [MATLAB] Math & Science Software 1
Matlab Plot Math & Science Software 2
3D Plot in Matlab Programming & Computer Science 6
Labelling the axis on a Maple plot Math & Science Software 0