添加颜色渐变图例以可视化节点中心

时间:2019-08-16 12:07:24

标签: osmnx

我是在python中使用osmnx包的初学者。来自https://github.com/gboeing/osmnx-examples/blob/master/notebooks/08-example-line-graph.ipynbin中的示例  我正在尝试可视化我的项目所需要的网络,这是国家丹麦的铁路网络。我能够用颜色渐变可视化网络上的节点中心度值。但是我想添加一个图例来显示值和相应的调色板,以便更好地理解,而不仅仅是说最低值代表深色区域,反之亦然。我尝试从其他软件包中实现图例功能,但最终无法获得图例。可能有一个我不知道的内置函数。如果有人对此提出建议,将会非常有帮助。

df = pd.DataFrame(data=pd.Series(node_centrality).sort_values(), columns=['cc'])
df['colors'] = ox.get_colors(n=len(df), cmap='inferno', start=0.2)
df = df.reindex(G.nodes())
nc = df['colors'].tolist()
fig, ax = ox.plot_graph(G, bgcolor='k', node_size=30, node_color=nc, node_edgecolor='none', node_zorder=2,
                        edge_color='#555555', edge_linewidth=1.5, edge_alpha=1)

实现的代码与示例中提供的代码相似,但为丹麦的铁路网络实现。

0 个答案:

没有答案