I have a geodataframe with points and some associated data. I want to plot it on a map using geopandas and have the size of the points correspond to one of the columns in the geodataframe.

So far I have the following code:

base = world.plot(color='white', figsize=(20,10))
geo_df.plot(ax=base, marker='.', color='red', markersize = 
plt.xlim([-85, -60])
plt.ylim([-5, 12.5]);

But I'm getting the following error: TypeError: cannot convert the series to <class 'float'>

Any ideas?

  • Is this all the code?
    – Fezter
    May 24, 2017 at 19:33
  • @Fezter that's all the code for drawing the map. There's more code for building the geodataframe but that didn't seem relevant here. Is there anything crucial missing here? Thanks. May 24, 2017 at 19:44
  • What is the field type of Pop_2005? Is it float or int?
    – Fezter
    May 24, 2017 at 19:55
  • 3
    Could it be that you can only set a single marker size, and it is expecting a single float value and not a series/list/tuple or floats? Jul 10, 2017 at 16:38
  • 1
    Would it be worth casting Pop_2005 explicitly to a float or integer? geo_df['Pop_2005'] = geo_df['Pop_2005'].astype(float)
    – om_henners
    Feb 10, 2018 at 10:57

1 Answer 1


In geopandas >= 0.3 (released September 2017), the plotting of points is based on the scatter plot method of matplotlib under the hood, and this accepts a variable markersize.

So now you can actually pass a column to markersize, what the OP did in the original question:

import geopandas

cities = geopandas.read_file(geopandas.datasets.get_path('naturalearth_cities'))
# adding a column with random values for the size
cities['values'] = np.abs(np.random.randn(len(cities))) * 50



enter image description here

Of course, if your goal is simply to change the markersize to a different constant value, you can still pass a single float to the keyword:

  • Is there a way to have the legend represent the marker sizes? Passing legend=True is ignored.
    – amball
    Apr 16, 2022 at 1:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.