TransWikia.com

Plotting two shapefiles in same plot. Legend of 1st shapefile hidden by second shapefile. Python GeoPandas

Geographic Information Systems Asked by braulio on January 7, 2021

With

ax = gdf.plot(cmap="jet", column=ColumnaAVisualizar, categorical=True,figsize=(12,12),legend=True)
ax2=ZDE.boundary.plot(ls="--",color="k", label="Zona de Estudio", ax=ax)
plt.show()

It gives:
enter image description here

Now with

ax = gdf.plot(cmap="jet", column=ColumnaAVisualizar, categorical=True,figsize=(12,12),legend=True)
l1=ax.legend(loc='center right', bbox_to_anchor=(1.0, 0.5))
ax2=ZDE.boundary.plot(ls="--",color="k", label="Zona de Estudio", ax=ax)
l2=ax2.legend(loc='center left', bbox_to_anchor=(1.0, 0.5))
ax.add_artist(l1)
plt.show()

It gives:

enter image description here

So I would like something with the two legends:

enter image description here

PS: Both gdf have the same CRS.

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP