Matplotlib动画:如何删除以前绘制的点?

时间:2020-05-25 08:59:33

标签: python-3.x matplotlib

我正在获取和绘制纬度和经度。我可以在绘图上对其进行动画处理,但是我希望在绘制下一个绘图点之前先删除先前绘制的点。另外,我该如何中断动画并转到代码的其余部分(例如下面的elif语句),这是我的代码的结构:

import cartopy.crs as ccrs
import matplotlib.pyplot as plt
from matplotlib import animation
fig=plt.figure(figsize=(10,8))
ax = plt.axes(projection=ccrs.PlateCarree())
ax.stock_img()
ax.gridlines(draw_labels=True, color='black', linestyle='-', alpha=0.2)


def calc(i)

#Here the latitude.degrees and longitude.degrees are calculated (acquired)

plt.scatter(longitude.degrees, latitude.degrees, color='Red', marker='o')


while True:


        if some condition:
          anim = animation.FuncAnimation(fig, calc, interval=100, blit=False)

          plt.show()

        elif some other condition: # I never get to this statement. If i close plot, the entire Gui 
                                   #closes

          some other code

window.close() # I am using pysimplegui

1 个答案:

答案 0 :(得分:0)

如果您以前的轴元素,例如@Override public boolean renameColumnPosition(int columnPosition, String customColumnName) { IDataProvider dataProvider = ((DefaultColumnHeaderDataLayer) this.getBaseLayer()).getDataProvider(); Object oldData = dataProvider.getDataValue(columnPosition, 0); boolean renamed = (!oldData.equals(customColumnName)); if (renamed) { dataProvider.setDataValue(columnPosition, 0, customColumnName); fireLayerEvent(new RenameColumnHeaderEvent(this, columnPosition)); } return renamed; } 存储在变量ax.plot(..,..)中。然后,您可以按以下步骤将其删除:

line