Skip to content

Commit

Permalink
Merge pull request #627 from martinfleis/explore_kwags
Browse files Browse the repository at this point in the history
pass kwargs to explore
  • Loading branch information
martinfleis committed Nov 3, 2023
2 parents 4290c11 + 9c17c03 commit 6072541
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
11 changes: 10 additions & 1 deletion libpysal/graph/_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ def _explore_graph(
node_kws=None,
focal_kws=None,
m=None,
**kwargs,
):
"""Plot graph as an interactive Folium Map
Expand Down Expand Up @@ -177,6 +178,10 @@ def _explore_graph(
passing a subset of nodes with the `focal` argument
m : Folilum.Map, optional
folium map objecto to plot on top of, by default None
**kwargs : dict, optional
additional keyword arguments are passed directly to geopandas.explore, when
``m=None`` by default None
Returns
-------
Expand Down Expand Up @@ -230,7 +235,11 @@ def _explore_graph(
["focal", "neighbor", "weight", "geometry"]
]

m = edges.explore(m=m, **edge_kws) if m is not None else edges.explore(**edge_kws)
m = (
edges.explore(m=m, **edge_kws)
if m is not None
else edges.explore(**edge_kws, **kwargs)
)

if nodes is True:
if focal is not None:
Expand Down
5 changes: 5 additions & 0 deletions libpysal/graph/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1288,6 +1288,7 @@ def explore(
node_kws=None,
focal_kws=None,
m=None,
**kwargs,
):
"""Plot graph as an interactive Folium Map
Expand All @@ -1314,6 +1315,9 @@ def explore(
passing a subset of nodes with the `focal` argument
m : Folilum.Map, optional
folium map objecto to plot on top of, by default None
**kwargs : dict, optional
additional keyword arguments are passed directly to geopandas.explore, when
``m=None`` by default None
Returns
-------
Expand All @@ -1330,6 +1334,7 @@ def explore(
node_kws=node_kws,
focal_kws=focal_kws,
m=m,
**kwargs,
)


Expand Down
6 changes: 6 additions & 0 deletions libpysal/graph/tests/test_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,3 +368,9 @@ def test_m(self):
assert s.count("LineString") == 6
# geoms
assert s.count("Polygon") == 5

def test_explore_kwargs(self):
m = self.G_str.explore(self.nybb_str, tiles="OpenStreetMap HOT")
s = fetch_map_string(m)

assert "tile.openstreetmap.fr/hot" in s

0 comments on commit 6072541

Please sign in to comment.