Geo
import marimo as mo
Geo Plot
In this notebook, we will see how to create geographic graph visualizations using the mid-level and high-level APIs.
# magic command not supported in marimo; please file an issue to add support
# %config InlineBackend.figure_format = 'retina'
# magic command not supported in marimo; please file an issue to add support
# %load_ext autoreload
# '%autoreload 2' command supported automatically in marimo
import pickle
from pyprojroot import here
import nxviz as nv
from nxviz import annotate, edges, layouts, nodes, plots, utils
with open(here() / "docs/examples/divvy.pkl", 'rb') as f:
G = pickle.load(f)
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
nv.geo(G_new, node_color_by='dpcapacity')
annotate.node_colormapping(G_new, color_by='dpcapacity')