将颜色向量传递到matplotlibBasmap

2024-04-27 18:35:17 发布

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

我已经用matplotlib Basemap创建了一个地图,并将通过在绘图中逐个绘制我的特殊点/标记来生成一个动画gif。那工作很好。 现在标记应该有一个特殊的颜色从生成的颜色向量。在该向量中,灰色值为(0.0-1.0)之间的值。 问题:将颜色向量传递到plot命令时,会导致以下错误:

raise ValueError('third arg must be a format string')

这是我代码的重要部分:

l, = m.plot([], [], [], marker='o', markersize=3)

xx=[]
yy=[]
ww=[]

for i in range(len(a)):
    xpt,ypt = m(long[i],lat[i])
    xx.append(xpt)
    yy.append(ypt)
    ww.append('0.55') # for a test the hole color vector is 0.55

data = np.vstack([xx,yy,ww])

def animate(num, data, point):
    point.set_data(data[0,:num],data[1,:num],data[2,:num])
    return point,

ani = animation.FuncAnimation(fig, animate, frames=len(data[1]), blit=True, fargs=(data,l), interval=500, repeat=False)

有什么想法吗?你知道吗


Tags: 标记fordatalenplot颜色向量num