3

I want to plot a geodataframe from Buenos Aires, the proportion of poor houses. There's the code:

import pandas as pd
import geopandas as gpd
import matplotlib.pyplot as plt
caba=gpd.read_file('https://bitsandbricks.github.io/data/CABA_rc.geojson')

The problem: the colorbar it's too big. I tried to pass some "legend_kwds" but there is an error.

fig, ax = plt.subplots(figsize=(10,10))
ax.set_aspect('equal')


caba.plot(ax=ax, column='HOGARES_NBI', cmap='viridis',edgecolor='grey',linewidth=0.01,
          facecolor='r', legend=True, legend_kwds={})

plt.title('Proporción de hogares \n con al menos una necesidad básica insatisfecha',fontsize=15)
ax.set_axis_off()

Here's the image of the really BIG colorbar

I tried to pass {'prop':{'size':2}} but it don't work.

The error: __init__() got an unexpected keyword argument 'prop'

Thanks!

Tomás
  • 31
  • 4
  • I believe you are not referring to a legend, but to the colorbar. At least this is what I learn from your image. You can find [here](https://stackoverflow.com/questions/18195758/set-matplotlib-colorbar-size-to-match-graph) many ways of how to scale the colorbar in a suited way, also especially for the usage of `GeoAxes` (see Bogdans Answer in the linked page) – gehbiszumeis Nov 13 '19 at 06:50
  • 1
    Thanks! I navigate through pages until this: https://geopandas.readthedocs.io/en/latest/mapping.html#creating-a-legend for the colorbar and this https://stackoverflow.com/questions/40796117/how-do-i-make-the-width-of-the-title-box-span-the-entire-plot?noredirect=1&lq=1 for the title. – Tomás Nov 13 '19 at 14:40

0 Answers0