I am using
contextily to plot building data (polygon) from OpenStreetMap. The problem is, the legend is overlapping the map. Is there any way to put the legend next to the map? or plot the map without legend, but export the legend separately from the map?
I hope the image helps.
here's my code to produce the map (I know the code is a little different, but it yields the same map):
from matplotlib import pyplot as plt import geopandas as gpd import contextily as ctx %matplotlib inline buildings = gpd.read_file("buildings.shp") fig, ax = plt.subplots(1,1,figsize=(9,9)) buildings.to_crs(epsg=3857).plot(column='building', ax=ax, cmap="Paired", legend=True) ctx.add_basemap(ax, url=ctx.providers.Esri.WorldTopoMap) ax.axis('off') plt.show()