Different plot size on Basemap

2.2k views Asked by At

I am currently using Basemap to plot some data. I would like the markersize to be defined by a list, but this throws an error.

Any idea how and I can show markers with varying sizes with a single function or method call?

m = Basemap(projection='mill',llcrnrlat=51.25,urcrnrlat=51.75,
            llcrnrlon=-0.5,urcrnrlon=0.3,resolution='h')
m.drawcoastlines()
m.drawrivers(color='blue')
m.fillcontinents()
m.drawmapboundary()
m.drawcounties()

lat,lon,size = [51.5, 51.4], [0.1, 0], [2, 35]
x, y = m(lon,lat)
m.plot(lon, lat,'ro',markersize=size)

plt.show()
2

There are 2 answers

2
B.Kocis On

You are forwarding a list and not a values for the markersize. size=[2,35], try size[0]

0
swenzel On

Basemap.plt does not support multiple marker sizes. Use Basemap.scatter with its size argument instead.
If you want to keep both lines and markers, you have to combine plot with scatter:

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

m = Basemap(projection='mill',llcrnrlat=51.25,urcrnrlat=51.75,
        llcrnrlon=-0.5,urcrnrlon=0.3,resolution='h')
m.drawcoastlines()
m.drawrivers(color='blue')
m.fillcontinents()
m.drawmapboundary()
m.drawcounties()

lat,lon,size = [51.5,51.4],[0.1,0],[2,35]
x,y = m(lon,lat)
m.plot(x, y, c='r')
m.scatter(x, y, s=size, c='r', marker='o', zorder=2)

plt.show()