# I have 3 figures, each with 2 x-axis and 2 y-axis, and i want to compine all 3 in a way similar to subplot, can anyone help?

1 view (last 30 days)
Sanad Ibdah on 16 Jun 2022
Answered: Anshika Chourasia on 23 Jun 2022
Each figure is created using the following code
T_density = density(:,1);
y_density = density(:,2);
T_st = surface_tension(:,1);
y_st = surface_tension(:,2);
x1 = T_density;
y1 = y_density;
x2 = T_st;
y2 = y_st;
t = tiledlayout(1,1);
ax1 = axes(t);
figure
plot(ax1,x1,y1,'-r')
ax1.XColor = 'r';
ax1.YColor = 'r';
ax2 = axes(t);
plot(ax2,x2,y2,'-k')
ax2.XAxisLocation = 'top';
ax2.YAxisLocation = 'right';
ax2.Color = 'none';
ax1.Box = 'off';
ax2.Box = 'off';
xlabel (ax1,'Temperature [K]')
xlabel (ax2,'Temperature [K]')
ylabel (ax1,'Desnity [kg/m^3]')
ylabel (ax2,'Surface Tension Coefficient')
##### 0 CommentsShow -2 older commentsHide -2 older comments

Sign in to comment.

### Answers (1)

Anshika Chourasia on 23 Jun 2022
Hi Sanad,
To create a configurable tiling of plots you can use the tiledlayout and nexttile functions.
For more information, refer the following link for combining multiple plots: https://www.mathworks.com/help/matlab/creating_plots/combine-multiple-plots.html .
##### 0 CommentsShow -2 older commentsHide -2 older comments

Sign in to comment.

### Categories

Find more on Line Plots in Help Center and File Exchange

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!