I'm trying to make a chloropleth map with geoplot on python and coming across a strange error.
import geopandas as gpd import geoplot as gplt import geoplot.crs as gcrs
map_geoplot = gpd.read_file("data/ADM1.geojson")
This is a geojson file that I'm sending to geoplot.
I merged the geojson dataframe with temperature data to get "merged_df".
Now for the plotting:
fig, ax = plt.subplots(figsize=(30, 8))
gplt.chloropleth(merged_df, hue=color_column, projection=gcrs.AlbersEqualArea(), cmap='coolwarm', legend=True,ax=ax)
gplt.polyplot(merged_df, projection=gcrs.AlbersEqualArea(), edgecolor='grey', linewidth=.7, ax=ax)
plt.show()
This comes up with the error 'Axes' object has no attribute 'set extent'. The error is raised as soon as I call the choropleth method. Any insight here would be great, I feel like I've looked everywhere. Thanks.
I'm expecting no error to be raised. I tried automatically setting the extent based on the GeoDataFrame's bounding box, but it didn't work. Code below:
ax.set_xlim(UZ.bounds.minx.min(), UZ.bounds.maxx.max())
ax.set_ylim(UZ.bounds.miny.min(), UZ.bounds.maxy.max())