Skip to content Skip to sidebar Skip to footer

How To Use Gridspec() With Funcanimation In Matplotlib?

Well, I want to make an animation which can show 4 different distributions, but when I use gridspec to make subplots, it doesn't work, the code is below: import matplotlib.animatio

Solution 1:

The GridSpec arguments wspace and hspace are incompatible with plt.tight_layout. You can either use tight_layout or specify the spacings.

If you want to use GridSpec you have two options:

  • remove the line plt.tight_layout
  • remove the line gspec.update(wspace = .6, hspace = .6)

The reason

fig, ((ax1,ax2),(ax3, ax4)) = plt.subplots(2, 2, sharey = True)
ax = [ax1, ax2, ax3, ax4]

works is therefore that you don't set any wspace or hspace.

Post a Comment for "How To Use Gridspec() With Funcanimation In Matplotlib?"