plt.yticks(np.arange(0, len(ax1) / r - 0.1, 1 / r), ax1_ticks)
plt.xticks(np.linspace(0, len(ax1), len(ax2)) + 0.5 / float(data.shape[1]),
    ax2_ticks)
plt.xlabel(ax1_label)
plt.ylabel(ax2_label)
plt.gca().invert_yaxis()
plt.axis('equal')
plt.axis([0, 7.02, 7 / r, -0.5])
scale = 0.5
plt.gcf().set_size_inches(data.shape[1] * scale, data.shape[0] * scale,
    forward=True)
Matplotlib: How to remove the vertical space when displaying circles on a grid?