简体   繁体   English

泡泡 map animation 使用 python

[英]Bubble map animation using python

I try to visualize carbon dioxide data.我尝试可视化二氧化碳数据。 In order to achieve this bubble animation effect in Python, how could I implement this?为了在Python中实现这个泡泡animation的效果,我该如何实现呢? I currently use the library of Altair.我目前使用 Altair 的库。

bubble effect气泡效应

Animation link: https://wpivis.github.io/hindsight/demos/co2/ Animation 链接: https://wpivis.github.io/hindsight/demos/co2/

Really appreciated for any suggestions非常感谢任何建议

This will not be supported in Altair/Vega-Lite until https://github.com/vega/vega/issues/641 is addressed.在解决https://github.com/vega/vega/issues/641之前,Altair/Vega-Lite 将不支持此功能。 You might be able to use Plotly animations for this, but I am unsure if they support fading in and out like in your example.您可以为此使用Plotly 动画,但我不确定它们是否像您的示例一样支持淡入淡出。 It seems like you could also use matplotlib for a similar effect, like what is suggested in this blog post :似乎您也可以使用 matplotlib 来达到类似的效果,就像这篇博文中建议的那样:

from matplotlib import pyplot as plt
from matplotlib.animation import FuncAnimation
import random
import numpy as np
  
x = []
y = []
colors = []
fig = plt.figure(figsize=(7,5))
  
def animation_func(i):
    x.append(random.randint(0,100))
    y.append(random.randint(0,100))
    colors.append(np.random.rand(1))
    area = random.randint(0,30) * random.randint(0,30)
    plt.xlim(0,100)
    plt.ylim(0,100)
    plt.scatter(x, y, c = colors, s = area, alpha = 0.5)
  
animation = FuncAnimation(fig, animation_func, 
                          interval = 100)
plt.show()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM