I'm attempting to animate a heatmap in matplotlib, which for the first time in a few hours is functioning, however the graph is very very small, as seen below.
The code I am using is as follows:
import numpy as np
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
import matplotlib.animation as animation
import xarray
Writer = animation.writers['ffmpeg']
writer = Writer(fps=15, metadata=dict(artist='Me'), bitrate=1800)
x = a[var]['lat'].values # Formatted as follows: [-32,-33,-34,-35,-36...]
y = a[var]['lon'].values # Formatted as follows: [150.2, 151.2, 153.2...]
z = np.array(a[var].values) # [[[24,22,18,23,24,24,25]
# [18,25,23,22,21,19,26]
# ...
# [12,28,19,22,25,26,19]]
# ...
# [[8,4,16,12,22,24,23,8]
# ...
# [12,28,14,7,8,13,6,12]]]
fig = plt.figure()
ax = fig.add_subplot(len(x),len(y),1)
def plot(i):
data = z[i]
heatmap = ax.pcolor(x, y, data)
ani = animation.FuncAnimation(fig, plot, interval=1, frames=20)
ani.save('im.mp4', writer=writer)
I should also mention attempting to call plt.subplots(x,y)
causes the console to freeze and after 5 minutes it still hadn't progressed.
If anyone has an ideas or suggestions they would be much appreciated.