Reputation: 13
I've always found matplotlib subplots confusing, and so I was wondering whether somebody could show how to generate the following arrangement of subplots: Subplot Image
Thanks in advance.
Upvotes: 1
Views: 136
Reputation: 5913
@Marc 's answer is fine, but perhaps easier and more flexible is:
fig, axs = plt.subplots(2, 2, gridspec_kw={'width_ratios':[2, 1]})
# if you really don't want 4 axes:
fig.delaxes(axs[1, 1])
Upvotes: 1
Reputation: 734
You can use plt.GridSpec to easily create differently sized subplots.
cols = 5 #number of columns in the grid
s = 2 #width of top right subplot in #cells
w = 1 #spacing between subplot columns
fig = plt.figure()
gs = plt.GridSpec(2, cols, figure=fig, wspace=w)
ax1 = fig.add_subplot(gs[0, :-s])
ax2 = fig.add_subplot(gs[0, -s:])
ax3 = fig.add_subplot(gs[1, :-s])
Upvotes: 2