# Creating choropleth map

**URL:** <https://forum.generic-mapping-tools.org/t/creating-choropleth-map/2622>\
**Category:** PyGMT Q&A\
**Created:** [February 13, 2022, 9:32pm UTC](https://forum.generic-mapping-tools.org/t/creating-choropleth-map/2622 "2022-02-13T21:32:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rs\_umd](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/rs_umd/32/2016_2.png) [@rs\_umd](https://forum.generic-mapping-tools.org/u/rs_umd)\
**Post date:** [February 13, 2022, 9:32pm UTC](https://forum.generic-mapping-tools.org/t/creating-choropleth-map/2622/1 "2022-02-13T21:32:50Z")

</div>

Thanks for an amazing library!

I want to plot a choropleth map similar to [How to color polygons of a geopandas dataframe in pygmt?](https://flint.soest.hawaii.edu/t/how-to-color-polygons-of-a-geopandas-dataframe-in-pygmt/1138), however, I am running across an issue:

```
    import pygmt
    fig = pygmt.Figure()
    fig.coast(
        region='d',
        projection='R20/8i',
        shorelines=True,
        water='lightblue',
        land='grey',
        frame=True,
    )
    attribute_df['randNumCol'] = np.random.randint(1, 60, attribute_df.shape[0], dtype=int)
    pygmt.makecpt(cmap="batlow", reverse=True, continuous=True, series=[1, 60, 10])
    print(attribute_df['randNumCol'])
    try:
        fig.plot(data=attribute_df, close=True, color='+z', aspatial="Z=randNumCol", cmap=True, label='randNumCol')
    except Exception as e:
        print(e)
    fig.colorbar()
    fig.savefig('aa.png', show=True)

```

However, I get the following error: `Unsupported numpy data type '<class 'numpy.object_'>'.`

`attribute_df` contains regional boundaries for all countries, and looks like below. It also contains a column called `shape` which contains shapely information on polygon. I am excluding that column here for brevity.

> Country region randNumCol  
> 0 comoros anjouan 7  
> 1 comoros moheli 46  
> 2 comoros ngazidja 2  
> 3 djibouti ali\_sabieh 26  
> 4 djibouti dikhil 27

How can I fix this or any tips on how to debug it?
