I am trying to plot routes on a map of Amsterdam, I have graphics backend set to 'Automatic' to be able to interact with the figure more. When I plot Amsterdam, there is no problem. But, as soon as I try to plot a new figure with routes on them through: "ox.plot_graph_route(G, route)" the plotted route on the map flashes briefly before closing again.
Putting graphics backend back to inline works, but zooming the figure gives gives horrible graphical results. So I'd like not to resort to that.
Any idea as to why this is happening? This is my code:
import osmnx as ox
import networkx as nx
import geopandas as gpd
import matplotlib.pyplot as plt
import pandas as pd
G = ox.graph_from_place('Amsterdam', retain_all=False, truncate_by_edge=False, simplify=False, custom_filter='["waterway"~"canal"]')
fig, ax = ox.plot.plot_graph(G)
edges = ox.graph_to_gdfs(G, nodes=False, edges=True)
edges.columns
edges.crs
edges.head()
orig_xy = (52.378928, 4.897664)
target_xy = (52.3653, 4.9024)
orig_node = ox.distance.nearest_nodes(G, orig_xy[1], orig_xy[0], return_dist=False)
print(orig_node)
target_node = ox.distance.nearest_nodes(G, target_xy[1], target_xy[0], return_dist=False)
print(target_node)
route = ox.distance.shortest_path(G, orig_node, target_node, weight='length', cpus=1)
fig, ax = ox.plot_graph_route(G, route)