python - 向 OSMnx 图中添加一个点

标签 python matplotlib osmnx

我正在尝试在 Jupyter 笔记本中的现有 OSMnx 图中添加一个点,如下所示

import osmnx as ox
import matplotlib.pyplot as plt

G = ox.graph_from_address('1600 Pennsylvania Ave NW, Washington, DC 20500', 
                          distance=500)

fig, ax = ox.plot_graph(G)

ax.scatter(-77.036498, 38.897270, c='red')

plt.show()

但我的观点(-77.036498, 38.897270)没有出现。有任何想法吗?
print (type(fig), type(ax))
<class 'matplotlib.figure.Figure'> <class 'matplotlib.axes._subplots.AxesSubplot'>

enter image description here

最佳答案

问题是ox.plot_graph将在您绘制您的观点之前显示您的图表。请注意,如果您设置 show=False , ox.plot_graph将默认关闭图窗。您将需要更改您的 ox.plot_graph到:

fig, ax = ox.plot_graph(G, show=False, close=False)

希望下图是您想要的:

enter image description here

关于python - 向 OSMnx 图中添加一个点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49460880/

相关文章:

python - Pandas SQL block 大小

python - docker 容器将监听队列大小增加到 128 以上

python - 使用 osmnx 从多边形检索数据

OSMnx : how to provide more complex feature into the custom_filter parameter

python - 在 matplotlib 中使用 savefig() 时的 unicode 文本

python - 删除几乎平行的 NetworkX 最短路径

整数转二进制: questions about efficiency的Python算法

python - 如何在python中打印elasticsearch的查询结果?

python - 当我将每个条形放在簇图顶部时,无法为每个条形设置不同的颜色

python - 在 matplotlib 中绘制 3d 数据