I have a code that uses matplotlib (python win32 v2.7.5) to plot contour plots with color bars that are animated or the contour gets updated. In order to update the plot, I delete the color bar axis while keeping the original plot axis untouched. In version 1.1.1 of matplotlib, the program was working okay, however, when I upgraded to 1.2.1 of matplotlib I started to notice my plot is getting squashed to the left by the color bar as seen in the attached images.
In V1.1.1, the plot looked like this after multiple iterations:
whereas in V1.2.1 the plot looks now like this:
As seen, the major plot is getting pushed to the left even if I am using subplots_adjust.
The code for the above plots is as follows:
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.mlab import bivariate_normal
from matplotlib.colors import LogNorm
delta = 0.5
x = np.arange(-3.0, 4.001, delta)
y = np.arange(-4.0, 3.001, delta)
X, Y = np.meshgrid(x, y)
Z = bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
fig = plt.figure()
fig.subplots_adjust(left=0.1, bottom=0.1, right=0.97, top=0.92)
ax = fig.add_subplot(1,1,1)
axim = ax.imshow(Z,norm = LogNorm())
cb = fig.colorbar(axim)
#Note: These are not replicated, I put them here to show how a refresh of the
# contour plot multiple times will look like
fig.delaxes(fig.axes[1])
fig.subplots_adjust(left=0.1, bottom=0.1, right=0.97, top=0.92)
cb = fig.colorbar(axim)
fig.delaxes(fig.axes[1])
fig.subplots_adjust(left=0.1, bottom=0.1, right=0.97, top=0.92)
cb = fig.colorbar(axim)
plt.show()
If i delete ALL axis and re-create them each time, then it looks ok even in new version, but I am thinking that this is not efficient process with animation.
Any ideas why what changed in 1.2.1 to make such behavior? Or any other suggestions to make it work again?