I am plotting a global choropleth map in Jupyter Notebook displaying each country’s share of electricity production from fossil fuels (%). I managed to plot the original shapefile on a map, so I know that the geometry data is correct.
However, when I merged the fossil fuel dataframe with the geometry data (successfully) and try to plot it, I receive the following error:
Image size of 833x81232 pixels is too large. It must be less than 2^16 in each direction.
<Figure size 1000x1000 with 1 Axes>
Note that currently, figsize=(10,10)
, but I have changed this to smaller values — nothing has worked. Also, I tried the dpi
argument, but then I get the following error:
LineCollection.set() got an unexpected keyword argument 'dpi'
This is the code I am using to plot the map with and without dpi
:
ax = df_countries_shape_2.boundary.plot(figsize=(10,10), dpi=40, edgecolor='black',linewidth=0.05)
df_countries_shape_2.plot(ax=ax, column='Fossil fuels - % electricity', legend='True', cmap='RdBu')
ax = df_countries_shape_2.boundary.plot(figsize=(10,10), edgecolor='black',linewidth=0.05)
df_countries_shape_2.plot(ax=ax, column='Fossil fuels - % electricity', legend='True', cmap='RdBu')
I’ve tried to find related forums for Geopandas but haven’t been successful. Could someone help me plot this choropleth map please?
I tried changing figsize
and dpi
, but changing figsize
returned the same error and dpi
wasn’t recognised as an argument.
Some forums mentioned using ax.get_xticks()
and ax.get_yticks()
, so I tried that but I don’t know how to use this information to help me scale down the number of pixels in my image.
Della is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2