注释城市名称

问题描述 投票:-1回答:1

我想在坐标xy=(52.52, 13.405)上标注柏林的城市名称。我尝试过ax.annotate(),它会产生一张奇怪的地图。也许与坐标的CRS有关?

import geopandas as gpd
import contextily as ctx

world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
world = world[(world.name=="Germany")]
world = world.to_crs(epsg=3857)

ax = world.plot(figsize=(10, 10), color='none', linewidth=1, alpha=0.5)
ax.annotate("Berlin", xy=(52.52, 13.405))

ctx.add_basemap(ax, url=ctx.providers.Stamen.Watercolor, zoom=9)

enter image description here

python matplotlib geopandas contextily
1个回答
2
投票

根据Annotations docpage,您的代码应如下所示:

ax.annotate("Berlin", xy=(52.52, 13.405))
© www.soinside.com 2019 - 2024. All rights reserved.