I'm trying to color a route by the attributes of individual edges along that route, which used to be possible in an earlier version of osmnx with the following syntax:
# just an example graph
G = ox.graph_from_point((42.35083, -71.089473), network_type='drive', dist_type='network',
simplify=False, dist=100)
# example route
route = [61354688, 7542547660, 5674166794, 61354678]
# color for each edge (4 nodes, 3 edges)
rcs = ['r', 'b', 'r']
ox.plot_graph_route(G, route, route_color=rcs)
This now throws the following error:
ValueError: 'c' argument has 3 elements, which is not acceptable for use with 'x' with size 2, 'y' with size 2.
I'm not sure how this was implemented previously, but it seemed like it could take a list with the same number of elements as there were edges in the route and color accordingly. Is there a new way to implement this? It seems like it's possible to color the entire graph by particular attributes, but not individual routes.
Any help would be appreciated!
As you can see in the docs, the
plot_graph_route
function takes aroute_color
argument as a string to define the color of the plotted route. If you want to give each edge its own color, you'll want to plot the route manually on top of the graph. Here's an example, loosely adapted from the OSMnx source code: