How to use the osmnx.plot_graph function in osmnx

To help you get started, we’ve selected a few osmnx examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gboeing / osmnx / tests / test_osmnx.py View on Github external
# test getting colors
    co = ox.get_colors(n=5, return_hex=True)
    nc = ox.get_node_colors_by_attr(G2, 'osmid')
    ec = ox.get_edge_colors_by_attr(G2, 'length')

    # save a plot to disk as png
    fig, ax = ox.plot_graph(G, save=True, file_format='png')

    # save a plot to disk as svg
    G_simplified = ox.simplify_graph(G)
    fig, ax = ox.plot_graph(G_simplified, show=False, save=True, close=True, file_format='svg')

    G_projected = ox.project_graph(G_simplified)
    fig, ax = ox.plot_graph(G_projected)

    fig, ax = ox.plot_graph(G_projected, fig_height=5, fig_width=5, margin=0.05, axis_off=False, bgcolor='y',
                            file_format='png', filename='x', dpi=180, annotate=True, node_color='k', node_size=5,
                            node_alpha=0.1, node_edgecolor='b', node_zorder=5, edge_color='r', edge_linewidth=2,
                            edge_alpha=0.1, use_geom=False, show=False, save=True, close=True)

    fig, ax = ox.plot_figure_ground(G=G_simplified, file_format='png')
    fig, ax = ox.plot_figure_ground(point=(33.694981, -117.841375), file_format='png')
    fig, ax = ox.plot_figure_ground(address='Denver, Colorado, USA', file_format='png')
github gboeing / osmnx / tests / test_osmnx.py View on Github external
def test_plots():
    G = ox.graph_from_place('Piedmont, California, USA', network_type='drive', simplify=False)
    G2 = ox.simplify_graph(G, strict=False)

    # test getting colors
    co = ox.get_colors(n=5, return_hex=True)
    nc = ox.get_node_colors_by_attr(G2, 'osmid')
    ec = ox.get_edge_colors_by_attr(G2, 'length')

    # save a plot to disk as png
    fig, ax = ox.plot_graph(G, save=True, file_format='png')

    # save a plot to disk as svg
    G_simplified = ox.simplify_graph(G)
    fig, ax = ox.plot_graph(G_simplified, show=False, save=True, close=True, file_format='svg')

    G_projected = ox.project_graph(G_simplified)
    fig, ax = ox.plot_graph(G_projected)

    fig, ax = ox.plot_graph(G_projected, fig_height=5, fig_width=5, margin=0.05, axis_off=False, bgcolor='y',
                            file_format='png', filename='x', dpi=180, annotate=True, node_color='k', node_size=5,
                            node_alpha=0.1, node_edgecolor='b', node_zorder=5, edge_color='r', edge_linewidth=2,
                            edge_alpha=0.1, use_geom=False, show=False, save=True, close=True)

    fig, ax = ox.plot_figure_ground(G=G_simplified, file_format='png')
    fig, ax = ox.plot_figure_ground(point=(33.694981, -117.841375), file_format='png')
    fig, ax = ox.plot_figure_ground(address='Denver, Colorado, USA', file_format='png')
github gboeing / osmnx / tests / test_osmnx.py View on Github external
G2 = ox.simplify_graph(G, strict=False)

    # test getting colors
    co = ox.get_colors(n=5, return_hex=True)
    nc = ox.get_node_colors_by_attr(G2, 'osmid')
    ec = ox.get_edge_colors_by_attr(G2, 'length')

    # save a plot to disk as png
    fig, ax = ox.plot_graph(G, save=True, file_format='png')

    # save a plot to disk as svg
    G_simplified = ox.simplify_graph(G)
    fig, ax = ox.plot_graph(G_simplified, show=False, save=True, close=True, file_format='svg')

    G_projected = ox.project_graph(G_simplified)
    fig, ax = ox.plot_graph(G_projected)

    fig, ax = ox.plot_graph(G_projected, fig_height=5, fig_width=5, margin=0.05, axis_off=False, bgcolor='y',
                            file_format='png', filename='x', dpi=180, annotate=True, node_color='k', node_size=5,
                            node_alpha=0.1, node_edgecolor='b', node_zorder=5, edge_color='r', edge_linewidth=2,
                            edge_alpha=0.1, use_geom=False, show=False, save=True, close=True)

    fig, ax = ox.plot_figure_ground(G=G_simplified, file_format='png')
    fig, ax = ox.plot_figure_ground(point=(33.694981, -117.841375), file_format='png')
    fig, ax = ox.plot_figure_ground(address='Denver, Colorado, USA', file_format='png')
github gboeing / osmnx / tests / test_osmnx.py View on Github external
def test_plots():
    G = ox.graph_from_place('Piedmont, California, USA', network_type='drive', simplify=False)
    G2 = ox.simplify_graph(G, strict=False)

    # test getting colors
    co = ox.get_colors(n=5, return_hex=True)
    nc = ox.get_node_colors_by_attr(G2, 'osmid')
    ec = ox.get_edge_colors_by_attr(G2, 'length')

    # save a plot to disk as png
    fig, ax = ox.plot_graph(G, save=True, file_format='png')

    # save a plot to disk as svg
    G_simplified = ox.simplify_graph(G)
    fig, ax = ox.plot_graph(G_simplified, show=False, save=True, close=True, file_format='svg')

    G_projected = ox.project_graph(G_simplified)
    fig, ax = ox.plot_graph(G_projected)

    fig, ax = ox.plot_graph(G_projected, fig_height=5, fig_width=5, margin=0.05, axis_off=False, bgcolor='y',
                            file_format='png', filename='x', dpi=180, annotate=True, node_color='k', node_size=5,
                            node_alpha=0.1, node_edgecolor='b', node_zorder=5, edge_color='r', edge_linewidth=2,
                            edge_alpha=0.1, use_geom=False, show=False, save=True, close=True)

    fig, ax = ox.plot_figure_ground(G=G_simplified, file_format='png')
    fig, ax = ox.plot_figure_ground(point=(33.694981, -117.841375), file_format='png')
    fig, ax = ox.plot_figure_ground(address='Denver, Colorado, USA', file_format='png')
github kuanb / peartree / peartree / plot.py View on Github external
# OSMnx is not a dependency anymore, so we should only allow the plot
    # function to work as a convenience, if the user has already installed
    # OSMnx
    try:
        import osmnx as ox  # noqa
    except ModuleNotFoundError:
        log(('Optional dependency: OSMnx must be installed to use the '
             'plot method in peartree'))

    # TODO: Build out custom plotting configurations but,
    #       in the meantime, use OSMnx's plotting configurations
    #       since they work well for the current use case and I
    #       also plan on incorporating OSMnx into this library
    #       down the road so it isn't too extraneous an import.
    fig, ax = ox.plot_graph(G,
                            fig_height=12,
                            show=False,
                            close=False,
                            node_color='#8aedfc',
                            node_size=5,
                            edge_color='#e2dede',
                            edge_alpha=0.25,
                            bgcolor='black')
    return (fig, ax)
github ppintosilva / anprx / anprx / animate.py View on Github external
Returns
    -------
    anim : FuncAnimation
    """

    start_time = time.time()

    # ----------------------------
    # Generate base fig
    # ----------------------------

    bbox = ox.bbox_from_point(point = camera.point,
                              distance = bbox_side)

    fig, axis = ox.plot_graph(
            camera.network,
            bbox = bbox,
            margin = margin,
            bgcolor = bgcolor,
            node_color = node_color,
            node_edgecolor = node_edgecolor,
            node_zorder = node_zorder,
            edge_color = edge_color,
            node_alpha = node_alpha,
            edge_linewidth = edge_linewidth,
            edge_alpha = edge_alpha,
            node_size = node_size,
            save = False,
            show = False,
            close = False,
            axis_off = True,
github ppintosilva / anprx / anprx / plot.py View on Github external
if color_candidate_edges:
        norm = colors.Normalize(vmin=0, vmax=1)
        cmap = plt.cm.ScalarMappable(norm=norm, cmap=probability_cmap)
        pcolor = { edge : cmap.to_rgba(p)
                   for edge, p in camera.p_cedges.items() }

        j = 0
        for u,v,k in camera.network.edges(keys = True, data = False):
            edge = Edge(u,v,k)
            if edge in camera.lsystem['cedges']:
                edges_colors[j] = pcolor[edge]
            j = j + 1

    # Plot it
    fig, axis = \
        ox.plot_graph(
            camera.network,
            bbox = bbox,
            margin = margin,
            bgcolor = bgcolor,
            node_color = nodes_colors,
            node_edgecolor = node_edgecolor,
            node_zorder = node_zorder,
            edge_color = edges_colors,
            node_alpha = node_alpha,
            edge_linewidth = edge_linewidth,
            edge_alpha = edge_alpha,
            node_size = node_size,
            save = False,
            show = False,
            close = False,
            axis_off = True,