quick update to @Lilith 's answer. Due to a Matplotlib update, the figure should now instead be started with
fig = plt.figure() ax=fig.add_subplot(projection='3d')