Plotting with different y-axes range in Matlab

Click For Summary
SUMMARY

This discussion focuses on plotting multiple datasets with different y-axis ranges in MATLAB. The user seeks assistance in combining six plots into a single graph, each with specified x and y ranges. A solution is provided using the MATLAB plot command, demonstrating how to overlay plots with different y-axis values while ensuring that the data arrays are of the same size. The example illustrates combining PLOT1 and PLOT6 effectively.

PREREQUISITES
  • Familiarity with MATLAB syntax and commands
  • Understanding of array manipulation in MATLAB
  • Basic knowledge of plotting functions in MATLAB
  • Experience with data visualization concepts
NEXT STEPS
  • Explore MATLAB's hold on command for layering multiple plots
  • Learn about MATLAB's yyaxis function for dual y-axes
  • Investigate customizing plot aesthetics using name/value pairs in MATLAB
  • Study MATLAB's data types and array operations for effective data handling
USEFUL FOR

Data analysts, engineers, and researchers who need to visualize multiple datasets with varying scales in MATLAB.

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','*')
 

Similar threads

  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 4 ·
Replies
4
Views
5K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
Replies
5
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K