使用属性、folium、python 数据框设置颜色
我希望 CircleMarker 使用参数设置颜色,有这种可能性吗?我有如下所示的数据框:
lon lat segment
ABMF00GLP -61.528 16.262 41
ABPO00MDG 47.229 -19.018 71
ACRG00GHA -0.207 5.641 16
AGGO00ARG -58.140 -34.874 4
AIRA00JPN 130.600 31.824 20
... ... ... ...
YKRO00CIV -5.240 6.871 16
ZAMB00ZMB 28.311 -15.426 90
ZECK00RUS 41.565 43.788 67
ZIM200CHE 7.465 46.877 81
ZIM300CHE 7.465 46.877 81
我可以添加具有相同颜色的标记,如下所示,不幸的是我不知道如何使其依赖于段。
for x in df.index:
folium.CircleMarker(list(np.array(df.loc[x])),
popup=x,
radius=3,
color = "red",
).add_to(m)
I would like CircleMarker to set the color using an argument, is there such a possibility? I have dataframe something like this below:
lon lat segment
ABMF00GLP -61.528 16.262 41
ABPO00MDG 47.229 -19.018 71
ACRG00GHA -0.207 5.641 16
AGGO00ARG -58.140 -34.874 4
AIRA00JPN 130.600 31.824 20
... ... ... ...
YKRO00CIV -5.240 6.871 16
ZAMB00ZMB 28.311 -15.426 90
ZECK00RUS 41.565 43.788 67
ZIM200CHE 7.465 46.877 81
ZIM300CHE 7.465 46.877 81
I can add markers with the same color like below, unfortunately I don't know how to make it segment dependent.
for x in df.index:
folium.CircleMarker(list(np.array(df.loc[x])),
popup=x,
radius=3,
color = "red",
).add_to(m)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
引入连续颜色图并在段列中设置最小值和最大值。将段值作为标记颜色设置中的参数。有关颜色图的更多信息,请参阅此内容。
Introduce a continuous colormap and set minimum and maximum values in segment columns. Takes a segment value as an argument in the marker color setting. See this for more information about colormaps.
Geopandas 具有非常有用的交互式地图。当您在 geopandas 数据帧上调用此方法时,它将返回 folium 地图实例。
要使用基于
segment
值的标记颜色,只需执行以下操作:请注意,您的数据框必须是 geopandas 数据框,而不仅仅是 pandas 数据框。
Geopandas has very useful interactive mapping. When you call this method on geopandas dataframe, it will return folium map instance.
For you to use color the markers based on the
segment
value, simply do:Please note that you dataframe has to be geopandas dataframe, not just pandas dataframe.