Search code examples
pythonpandasmatplotlibgeopandas

How can I increase the number of bins for my plot using pandas / geopandas?


Currently a lot of my data is showing with a huge range of values in one bin - all data goes from 0 to 1.31, but my top bin colour is holding 0.15 to 1.31.

This is my code to plot:

merged.plot(column='vaccinations_per_person', scheme="quantiles", figsize=(25, 20),
           legend=True, norm=colour, cmap='Oranges', missing_kwds = 
           dict(color = "lightgrey", label = "No Data"))
plt.title('Vaccinations per Person',fontsize=25)

And this is my legend:

screen-grab of my legend


Solution

  • You can do it easily by specifying the number of bins as k=10 (if you want 10).

     merged.plot(column='vaccinations_per_person', scheme="quantiles", figsize=(25, 20),
               legend=True, norm=colour, cmap='Oranges', missing_kwds = 
               dict(color = "lightgrey", label = "No Data"), k=10)