问题
I'm trying to plot the graph of edge centrality on the folium using the following code
graph_map = ox.plot_graph_folium(G, popup_attribute='name', tiles='stamenterrain', edge_color=ec, edge_width=2)
where ec is list of edge colors but it is not showing up. Does edge_color accept a list of colors ? Any ideas?
I really appreciate if you can help me.
https://github.com/gboeing/osmnx-examples/blob/master/notebooks/08-example-line-graph.ipynb
回答1:
I tried adding a new column of edge color to gdf of the graph edges
gdf_edges = ox.graph_to_gdfs(G, nodes=False, fill_edge_geometry=True)
gdf_edges['edge_color'] = ec
Then modify two function
make_folium_polyline(edge, edge_width, edge_opacity, popup_attribute=None)
and
plot_graph_folium(gdf_edges, graph_map=None, popup_attribute=None, tiles='cartodbpositron', zoom=1, fit_bounds=True, edge_width=5, edge_opacity=1)
The final result is achieved
来源:https://stackoverflow.com/questions/49546015/osmnx-visualize-the-graph-of-edge-centrality-on-folium