Geo Plot
Geo Plot
In this notebook, we will see how to create geographic graph visualizations using the mid-level and high-level APIs.
%config InlineBackend.figure_format = 'retina'
%load_ext autoreload
%autoreload 2
import matplotlib.pyplot as plt
import networkx as nx
import nxviz as nv
from nxviz import edges, layouts, nodes, plots, utils, annotate
from pyprojroot import here
G = nx.read_gpickle(here() / "docs/examples/divvy.pkl")
G_new = G.copy()
for n1, n2, d in G.edges(data=True):
if d["count"] < 150:
G_new.remove_edge(n1, n2)
Mid-level API
nt = utils.node_table(G_new)
pos = nodes.draw(
G_new,
layout_func=layouts.geo,
group_by=None,
sort_by=None,
color_by="dpcapacity",
encodings_kwargs={"size_scale": 0.0015},
)
edges.line(G_new, pos)
annotate.node_colormapping(G_new, color_by="dpcapacity")
plots.rescale(G)
plots.aspect_equal()
plots.despine()
High-level API
from nxviz import annotate
nv.geo(G_new, node_color_by="dpcapacity")
annotate.node_colormapping(G_new, color_by="dpcapacity")