Python 如何在带有标签的地图上可视化networkx图形?

Python 如何在带有标签的地图上可视化networkx图形?,python,matplotlib,graph,leaflet,networkx,Python,Matplotlib,Graph,Leaflet,Networkx,我遵循此答案,但无法修改它以显示节点标签。这是我正在使用的代码 import matplotlib.pyplot as plt import mplleaflet import networkx as nx small_graph = nx.Graph() small_graph.add_node('1') small_graph.add_node('2') small_graph.add_node('3') small_graph.add_node('4') small_graph.add_

我遵循此答案,但无法修改它以显示节点标签。这是我正在使用的代码

import matplotlib.pyplot as plt
import mplleaflet
import networkx as nx

small_graph = nx.Graph()
small_graph.add_node('1')
small_graph.add_node('2')
small_graph.add_node('3')
small_graph.add_node('4')
small_graph.add_edge('1', '2')
small_graph.add_edge('3', '2')
small_graph.add_edge('3', '4')


pos = {'1': [55, 10], '2': [56, 11], '3': [57, 12], '4': [58, 12]}
labels = {'1': 'Node 1', '2': 'Node 2', '3': 'Node 3', '4': 'Node 4'}


fig, ax = plt.subplots()

nx.draw_networkx_nodes(small_graph,pos=pos,node_size=40,node_color='red',edge_color='k',alpha=.5)
nx.draw_networkx_edges(small_graph,pos=pos,edge_color='gray', alpha=.4)
nx.draw_networkx_labels(small_graph,pos=pos, labels=labels, font_size=10)


plt.show()
# mplleaflet.display(fig=fig)

如果我使用标准的
plt.show()
我可以看到正确显示的标签。但是,如果我取消注释最后一行以在地图上显示此图形,我只会发现这绝对不是字体大小的问题,因为调整此值没有任何区别。这有可能实现吗?如果没有,你推荐什么替代方案?

尝试反转坐标:
{'1':[10,55],'2':[11,56],'3':[12,57],'4':[12,58]}
@swatchai谢谢你的回答。它仍然不显示任何标签。它只是改变节点的位置,但对标签没有影响,这可能是一个a
zorder
问题。如果显式地将文本对象放置为高zorder,例如通过在
plt.show()
之前添加以下内容:
t=ax.text(55,10,'Node 1');t、 set_zorder(1000)
?似乎mplLeavet不支持文本对象:不,不用担心。我认为必须支持显示图像。因此,也许你可以通过制作带有png文本的小子框来绕过对文本的限制。