Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I increase the spacing between subplots with subplot2grid?

I use subplot2grid to make a subplot like the following:

enter image description here

In order to make the ticks sufficiently large for publication, I need to increase the vertical and horizontal spacing between axes.

Normally, I would use something like subplot_adjust(hspace = 0.5), but that doesn't seem to work with subplot2grid.

Could anyone please recommend a solution?

Here is the code I use to plot things and create the axes:

import matplotlib.pyplot as plt

ax1  = plt.subplot2grid((2,2),(0,0), colspan = 2)
ax2  = plt.subplot2grid((2,2),(1,0), colspan = 1)
ax3  = plt.subplot2grid((2,2),(1,1), colspan = 1)

df.plot( ax = ax1)
plt.show()
like image 751
Demetri Pananos Avatar asked Jan 02 '16 23:01

Demetri Pananos


1 Answers

I've found the solution here

The code is as follows:

AX = gridspec.GridSpec(2,2)
AX.update(wspace = 0.5, hspace = 0.5)
ax1  = plt.subplot(AX[0,:])
ax2 = plt.subplot(AX[1,0])
ax3 = plt.subplot(AX[1,1])

Which produces the same subplots with increased horizontal and vertical spacing.

like image 166
Demetri Pananos Avatar answered Nov 08 '22 16:11

Demetri Pananos