With more recent versions of matplotlib I'm getting distorted labels on animated plots. Is anybody else getting this? Am I doing something wrong?
Minimum working example:
from netCDF4 import Dataset
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
import matplotlib.animation as animation
from IPython import display
print(matplotlib.__version__)
# Make a random array of data to plot
r = np.random.rand(10,100,100)
fig, ax = plt.subplots(1,1,figsize=(10,10))
# Initiate Plot
plot = ax.pcolormesh(range(0,100),
range(0,100),
r[0],
cmap='RdBu')
cb = fig.colorbar(plot)
cb.set_label('Temperature')
def animate(frame):
C = r[frame][:-1,:-1]
plot.set_array(C)
ani = animation.FuncAnimation(fig,
animate,
frames= range(0,r.shape[0]),
)
video = ani.to_html5_video()
html = display.HTML(video)
display.display(html)
plt.close()
My labels seem like they're being placed many times (although this bug persists even when the animation only has two frames), and they appear like this:
This behaviour does not occur if I comment out all the lines below the ax.pcolormesh... which creates static plot that looks fine.
I'm on matplotlib 3.3.2
