有一个类似的问题here,但我没有同样的问题。以下是我的数据集快照:
基本上,我想随着时间的推移来设置降落坐标的动画。如您所见,日期按dropoff_datetime
排序。这是我的代码(与上面的问题非常相似)。在
fig = plt.figure(figsize=(10,10))
ax = plt.axes(xlim=xlim, ylim=ylim)
points, = ax.plot([], [],'.',alpha = 0.4, markersize = 0.05)
def init():
points.set_data([], [])
return points,
# animation function. This is called sequentially
def animate(i):
x = test["dropoff_longitude"]
y = test["dropoff_latitude"]
points.set_data(x, y)
return points,
anim = animation.FuncAnimation(fig, animate, init_func=init,
frames=100, interval=20, blit=True)
plt.show()
与上述问题中的问题类似,我的情节只是空洞地出现。我相信我的编码是正确的,与上面的链接不同,我确实看到坐标随着时间的推移而变化。我不知道为什么这个情节是空的。在
默认情况下,一个像素为1点或0.72点(取决于您是在jupyter笔记本中运行代码还是作为独立绘图运行代码)。如果创建markersize为}像素。由于在屏幕上很难看到1个像素,特别是当alpha设置为0.4时,观察像素的二十分之一是完全不可能的。在
0.05
的绘图,则每个标记的大小分别为0.05
像素或{解决方案:设置
markersize = 5
或更高。完整的工作示例:
相关问题 更多 >
编程相关推荐