如何模拟死亡率并将其想象为在tim上消失的圆点

2024-06-16 10:46:27 发布

您现在位置:Python中文网/ 问答频道 /正文

所以,我刚刚用scipy解决了一个人口死亡率的ODE模型,并绘制了一个2d图。我想如果我能把人口想象成以颂歌定义的死亡率消失的圆点会很有趣。有什么好的Python库和GUI可以处理这个问题?在

添加。信息:

我是如何解决这些问题的:

import scipy.integrate as spi
import numpy as np
import pylab as pl

L = 1500
alpha = 0.25
sigma = 0.75
TS = 1.0
ND = 120
m = 0.24
mu = 0.06
w = 10000
H0 = 45000 #initial number of hive bees
F0 = 15000 #initial number of forager bees
INPUT = (H0, F0)

def death_rates(INP, t):
    Y = np.zeros((2))
    V = INP #V[0] = H, V[1] = F
    Y[0] = ((L*(V[0]+V[1]))/(w+V[0]+V[1])) - V[0]*(alpha - sigma*(V[1]/(V[0]+V[1]))) - mu*V[0]
    Y[1] = V[0]*(alpha - sigma*(V[1]/(V[0]+V[1]))) - m*V[1]
    return Y

t_start = 0.0; t_end = ND; t_inc = TS
t_range = np.arange(t_start, t_end+t_inc, t_inc)
RES = spi.odeint(death_rates, INPUT, t_range)

print RES
pl.subplot(311)
pl.plot(RES[:,0], '-g', label='Hive Bees')
pl.xlabel('Time')
pl.ylabel('Hive Bees')
pl.subplot(312)
pl.plot(RES[:,1], '-r', label='Forager Bees')
pl.xlabel('Time')
pl.ylabel('Forager Bees')
pl.show()

生成了以下图表: 2D plot of the population decline

基本上,我想做的是将结果动画化,最初在种群数量N0处的圆点(蜜蜂)不断消失,直到在种群N1处停留60秒。在


Tags: importalphaspiasnpresscipysigma
1条回答
网友
1楼 · 发布于 2024-06-16 10:46:27

巧妙地使用Python。此链接末尾的“gapminder”示例与您想要的类似。在

向下滚动到结尾。在

https://plot.ly/python/animations/

这是一个屏幕截图-但它是最好的动画:

enter image description here

如果没有示例数据和关于所需内容的更多详细信息,就无法真正为您提供更多信息(我可以将一些与您描述的内容相匹配的内容可视化)。在

相关问题 更多 >