Can I arrange 3 equally sized subplots in a triangular shape?
matlab, matplotlib, python
Solution
Use `subplot` with range:
img = imread('cameraman.tif');
figure;
subplot(4,4,[2 3 6 7]);imshow(img);
subplot(4,4,[9 10 13 14]);imshow(img);
subplot(4,4,[11 12 15 16]);imshow(img);
And the result is:
A `matplotlib` solution based on `subplot2grid`
import matplotlib.pyplot as plt
plt.subplot2grid( (4,4), [0,1], 2, 2 )
plt.plot( x1, y1 )
plt.subplot2grid( (4,4), [2,0], 2, 2 )
plt.plot( x2, y2 )
plt.subplot2grid( (4,4), [2,2], 2, 2 )
plt.plot( x2, y2 )
Gives the following result:
Problem
To make this clear, I will use an 4x4 grid to show where and how large I want my subplots. The counting goes like this: ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 ``` I want the top plot to be placed over 2, 3, 6, and 7. The two bottom plots are then 9, 10, 13, 14 and 11, 12, 15, 16, respectively. In Matlab, you can use a subplot range, but I believe this only works for single row configurations. How can I do this in matplotlib? Do I need a gridspec? How would I use it then? The examples are insufficient to understand how I should tackle this problem.