Hi,

I want to show some points on a world map. But the color of a point is
linked to the value at the point. Any idea why the code below does not give
what I want (same color, no legend)?

Many thanks,
Tom

from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
import numpy as np

lats = [47.8, -54.85, 47.0544, 44.18, 47.42, 46.55]
lons = [11.02, -68.32, 12.9583, 10.7, 10.98, 7.99]
scores = [4.93657698397, -31.0626756529, 35.2049971001, 23.1060270438,
12.5139213403, 17.3946319493]

map = Basemap(projection = 'mill')
map.drawcoastlines()
map.drawmapboundary()

for lat, lon, score in zip(lats, lons, scores):
    print('Score at (%f, %f) is %f' % (lat, lon, score))
    x, y  = map(lon, lat) # Notice x = lon, y = lat
    map.scatter(x, y, marker = 'o',
                s = 500,
                c = score,
                cmap = plt.get_cmap('rainbow'))

plt.legend()
plt.show()
------------------------------------------------------------------------------
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to