Python:使用赛璐珞制作动画时,轴在图形中消失

Python:使用赛璐珞制作动画时,轴在图形中消失,python,matplotlib,jupyter-notebook,cartopy,celluloid,Python,Matplotlib,Jupyter Notebook,Cartopy,Celluloid,我用赛璐珞()在几年内绘制了一个函数,到目前为止我很喜欢它,它工作得很好! 不过我有一个小问题,在第一次循环后,我的图的边缘消失了。我附上了这张照片 第一个循环: 第二个循环: 正如你所看到的,轴已经消失了。我在jupyter笔记本中使用cartopy和matplotlib,这是我的动画代码: # Use 'Agg' so script only displays animation in HTML import matplotlib matplotlib.use('Agg') from I

我用赛璐珞()在几年内绘制了一个函数,到目前为止我很喜欢它,它工作得很好! 不过我有一个小问题,在第一次循环后,我的图的边缘消失了。我附上了这张照片

第一个循环:

第二个循环:

正如你所看到的,轴已经消失了。我在jupyter笔记本中使用cartopy和matplotlib,这是我的动画代码:

# Use 'Agg' so script only displays animation in HTML
import matplotlib
matplotlib.use('Agg')
from IPython.display import HTML
# Use celluloid as this is a way easier method to animate than matplotlib
from celluloid import Camera

# Sets up the map plot with coastlines from cartopy and the PlateCarree projection
# The PlateCarree projection is neither equal area nor conformal, thus it is mostly used for thematic 
mapping
fig=plt.figure(figsize=(9,5))
cmap=matplotlib.cm.RdBu_r 
norm=matplotlib.colors.Normalize(vmin=0, vmax=50)
ax=plt.axes(projection=ccrs.PlateCarree(),extent=[-180, 180, -90, 90])
# Set labels and ticks for x- and y-axis
ax.set_xticks([-180, -120, -60, 0, 60, 120, 180], crs=ccrs.PlateCarree())
ax.set_yticks([-90, -60, -30, 0, 30, 60, 90], crs=ccrs.PlateCarree())
plt.xlabel('Longitude [deg]')
plt.ylabel('Latitude [deg]')

# Defines camera and executes plot every year in chosen time range
camera = Camera(fig)
for i in range(0,(stop-start)+1):
    plt.scatter(nphi[i], nthe[i], c=mag[i], s=40, norm=norm, cmap=cmap, edgecolor="k")
    ax.text(0, 1.05, 'Global Observatory Plot of SV magnitude from target year ' 
             + str(start+i) + ' in the dB_' + out + '-direction', fontsize=9, transform=ax.transAxes)
    ax.coastlines()
    camera.snap()

# Sets up colourbar and set a label
cbar=plt.colorbar()
cbar.set_label('Magnitude of SV [nT/yr$^2$]')

# Create animation with slower interval between plots, saves the animation, and displays it as HTML video
animation = camera.animate(interval=800)
animation.save('Figures/GlobalSVMag.mp4')
HTML(animation.to_html5_video())

有没有办法使边在动画中始终显示?即使对于没有赛璐珞使用经验的用户,您是否也遇到过轴消失的问题,如果是,您是如何解决的?

您是否尝试不使用赛璐珞,而是使用通常的内置
FuncAnimation
?在这种情况下,
celluloid
标记适用于该名称的
Ruby
库。我尝试使用FuncAnimation,但发现它很难与当前函数一起使用。我可能会再试一次,但有没有办法只在轴上旋转或其他什么的?