Je tracer une carte en utilisant geopandas
et colormap
avec le code:Zooming et sauver seulement une partie centrale d'intérêt dans un matplotlib geopandas figurent
import numpy as np
## make up some random data
df = pd.DataFrame(np.random.rand(20, 3), columns=['x', 'y', 'val'])
df['geometry'] = df.apply(lambda row: shapely.geometry.Point(row.x, row.y), axis=1)
# make it a geopandas DataFrame
gdf = gpd.GeoDataFrame(df)
## the plotting
ax = gdf.plot(column='val', colormap='hot', vmin=vmin, vmax=vmax)
# add colorbar
fig = ax.get_figure()
cax = fig.add_axes([0.9, 0.1, 0.03, 0.8])
sm = plt.cm.ScalarMappable(cmap='hot', norm=plt.Normalize(vmin=0, vmax=1))
# fake up the array of the scalar mappable. Urgh...
sm._A = []
fig.colorbar(sm, cax=cax)
Ensuite, je reçois ce chiffre (les données sont différentes de l'exemple ci-dessus)
Comme vous pouvez le voir, les entreprises d'intérêt sont au centre de la carte.
Je voudrais fournir une enveloppe coordonnées, ReZoom l'image, en gardant la colorbar et savefig()