Figure Subplot Tiles Customization
10 次查看(过去 30 天)
显示 更早的评论
I want to create a figure containing subplots such that there are 3 columns. The first two columns are supposed to have three subplots each row wise but the last column should have 2 tiles only. How can I do this using the subplot command? I've attached a sample picture of the figure that I want.
0 个评论
采纳的回答
Benjamin Kraus
2023-1-24
编辑:Benjamin Kraus
2023-1-24
I don't see an attached picture, but I think I understand what you are trying to do.
First, I recommend trying tiledlayout instead of subplot, but both can handle what you are trying to do. tiledlayout and nexttile are newer than subplot and provide a few new features that should make this tast easier.
Conceptually, what you want is a grid that is 6 rows and 3 columns, then you want tiles in the grid to be either 2 or 3 rows tall.
t = tiledlayout(6,3);
ax11 = nexttile(1,[2 1]); % First column, top two rows
ax21 = nexttile(2,[2 1]); % Second column, top two rows
ax31 = nexttile(3,[3 1]); % Third column, top three rows
ax12 = nexttile(7,[2 1]); % First column, next two rows
ax22 = nexttile(8,[2 1]); % Second column, next two rows
ax32 = nexttile(12,[3 1]); % Third column, bottom three rows
ax13 = nexttile(13,[2 1]); % First column, bottom two rows
ax23 = nexttile(14,[2 1]); % Second column, bottom two rows
figure
ax11 = subplot(6,3,[1 4]); % First column, top two rows
ax21 = subplot(6,3,[2 5]); % Second column, top two rows
ax31 = subplot(6,3,[3 6 9]); % Third column, top three rows
ax12 = subplot(6,3,[7 10]); % First column, next two rows
ax22 = subplot(6,3,[8 11]); % Second column, next two rows
ax32 = subplot(6,3,[12 15 18]); % Third column, bottom three rows
ax13 = subplot(6,3,[13 16]); % First column, bottom two rows
ax23 = subplot(6,3,[14 17]); % Second column, bottom two rows
4 个评论
Benjamin Kraus
2023-1-25
@Fawad Farooq Ashraf: You shouldn't have that problem with either subplot or tiledlayout, but out of curiosity: Which one are you using?
It should be fairly difficult to have that issue with tiledlayout.
There are lots of ways to accidentally cause an axes to "break out" of a subplot, which can cause this issue. I suggest using tiledlayout if you are not already.
Either way, if you want assistance fixing that issue, post your code so I can get a better idea of what might be happening.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Subplots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!