My question is very closely related to this questions and maybe to this one as well, although the solution of the latter didn't help me.
My code must generate a simple plot and save it:
def bizarre():
x = np.arange(-5,5)
y = np.arange(-10,10)
xc,yc = np.meshgrid(x,y)
zc = np.random.randint(-1,2,size=xc.shape)
plt.figure()
m = plt.pcolormesh(xc, yc, zc, shading='nearest', cmap='coolwarm',
edgecolors='gray', linewidths=1, vmin=-1, vmax=1,
in_layout=False,)
plt.colorbar(m)
ax = plt.gca()
ax.set_aspect('equal')
plt.tight_layout()
plt.savefig('bizzare.png', dpi=200)
bizarre() # saves a figure with bizarre size
The function works perfectly fine and generates something like this in a Jupyter cell:
Yet, for some mysterious reason, I get blank space on the left side of the saved figure. Something like this:
I'm genuinely interested to know why is that? Thanks.