如何在Geopandas Geoplot中添加标签?
假设我有以下数据集:
import geopandas as gpd
world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
world.plot()
我要实现的目标是用标签绘制数据,以添加列的相应值iso_a3
和pop_est
作为标签图上的每个几何形状。
谢谢
Let's say I have the following dataset:
import geopandas as gpd
world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
world.plot()
What I want to achieve is to plot the data with labels, for instance, to add corresponding values of columns iso_a3
and pop_est
as labels on each geometry on the plot.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 lambda 函数绘制标签。
在这种情况下,标签绘制在每个多边形的中心。如果您想绘制更多标签,您可以使用质心加上一个小的偏移量。
Use a lambda function to plot the labels.
In this case the labels are plotted in the center of each polygon. In case you want to plot more labels you case use the centroid plus a small offset.