我正在尝试使用以下代码在叶片上绘制边中心性图
graph_map = ox.plot_graph_folium(G,
popup_attribute='name',
tiles='stamenterrain',
edge_color=ec,
edge_width=2)
其中 ec 是边缘颜色列表,但未显示。 edge_color 是否接受颜色列表?有什么想法吗?
如果您能帮助我,我将不胜感激。
https://github.com/gboeing/osmnx-examples/blob/master/notebooks/08-example-line-graph.ipynb
请您参考如下方法:
我尝试向图形边缘的 gdf 添加一个新的边缘颜色列
gdf_edges = ox.graph_to_gdfs(G,
nodes=False,
fill_edge_geometry=True)
gdf_edges['edge_color'] = ec
然后修改两个函数
make_folium_polyline(edge, edge_width, edge_opacity, popup_attribute=None)
和
plot_graph_folium(gdf_edges, graph_map=None, popup_attribute=None,
tiles='cartodbpositron', zoom=1, fit_bounds=True,
edge_width=5, edge_opacity=1)
最终结果实现:
