mcatis
mcatis

Reputation: 1266

Passing color vector to matplotlib-Basmap

I've created a map with matplotlib-Basemap and will have an animated gif by drawing my special points / markers one by one in the plot. That work's fine. Now the markers should have a special color from a generated color-vector. In this vector are values from (0.0-1.0) for grey values. Problem: Passing the color vector to the plot command, cause this error:

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

This is the important part of my code:

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)

Any ideas?

Upvotes: 1

Views: 130

Answers (1)

Louis
Louis

Reputation: 2890

the "plot" expects one or two vectors.

This works in your sample :

l, = m.plot([1,2,3], [3,4,5], marker='o', markersize=3)

Upvotes: 1

Related Questions