Reputation: 101
I've created this map using geopandas, but I can't make the color bar have the same size as the figure.
ax = covid_death_per_millon_geo.plot(column = 'total_deaths_per_million', legend = True, cmap = 'RdYlGn_r', figsize=(20,15))
ax.set_title('Covid deaths per Million', size = 20)
ax.set_axis_off()
https://i.sstatic.net/a26oJ.png
Upvotes: 5
Views: 3148
Reputation: 538
The colorbars on GeoPandas plots are Matplotlib colorbar
objects, so it's worth checking those docs.
Add a legend_kwds
option and define the shrink
value to change the colorbar's size (this example will shrink it to 50% of the default):
ax = covid_death_per_millon_geo.plot(
column="total_deaths_per_million",
legend=True,
legend_kwds={
"shrink":.5
},
cmap="RdYlGn_r",
figsize=(20, 15)
)
Alternatively, change the colorbar's location
to put it below the map. You may want to change both the location and the size:
ax = covid_death_per_millon_geo.plot(
column="total_deaths_per_million",
legend=True,
legend_kwds={
"location":"bottom",
"shrink":.5
},
cmap="RdYlGn_r",
figsize=(20, 15)
)
Upvotes: 4