How to put 2 subplots as 1 subplot without merging their data?
4 views (last 30 days)
Show older comments
I have created five subplots in one figure, where the data was grouped based on the country, say: Country A, B, C, D and E.
Question: Instead of having five subplots, now I want only four subplots, where the subplots of C and D are to be merged as one subplot, i.e. subplot 1: A, subplot 2: B, subplot 3: C & D and subplot 4: E. How to modify my code below?
Condition: Although the C & D are put together, I still want their results are shown individually in the same subplot 3.
figure (01)
[u_Country, ~, idx] = unique(Table1.Country);
for k = 1:5
subplot(3,2,k)
mask = idx == k;
f1 = gscatter(Table1.x(mask), Table1.y(mask), Table1.Country(mask), 'mgbrk', 'xxxxx');
xlim([0 100]);
ylim([20 50]);
legend(f1((u_Country(k))), 'Location', 'northeast');
end
0 Comments
Answers (1)
Stephen Jue
on 22 Jun 2017
If I understand correctly, you would like to create a 2 x 2 quadrant of subplots, where the 3rd (bottom left) subplot is split into two subplots.
You can do this by creating a 4 x 4 subplot and specifying the positions of each plot as a vector. Each subplot spans a 2 x 2 range of positions, except the two on the bottom left, which each span a 1 x 2 range. Here is the code:
subplot(4,4,[1 6]) % top left
subplot(4,4,[3 8]) % top right
subplot(4,4,[9 10]) % bottom left (1)
subplot(4,4,[13 14]) % bottom left (2)
subplot(4,4,[11 16]) % bottom right
0 Comments
See Also
Categories
Find more on Subplots 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!