diff --git a/xgi/drawing/draw.py b/xgi/drawing/draw.py index 6590120c8..238de0514 100644 --- a/xgi/drawing/draw.py +++ b/xgi/drawing/draw.py @@ -48,6 +48,7 @@ def draw( max_order=None, node_labels=False, hyperedge_labels=False, + aspect="equal", **kwargs, ): """Draw hypergraph or simplicial complex. @@ -110,6 +111,11 @@ def draw( hyperedge_labels : bool or dict, optional If True, draw ids on the hyperedges. If a dict, must contain (edge_id: label) pairs. By default, False. + aspect : {"auto", "equal"} or float, optional + Set the aspect ratio of the axes scaling, i.e. y/x-scale. `aspect` is passed + directly to matplotlib's `ax.set_aspect()`. Default is `equal`. See full + description at + https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.set_aspect.html **kwargs : optional args Alternate default values. Values that can be overwritten are the following: * min_node_size @@ -216,6 +222,8 @@ def draw( # compute axis limits _update_lims(pos, ax) + ax.set_aspect(aspect, "datalim") + return ax @@ -1209,6 +1217,7 @@ def draw_hypergraph_hull( node_labels=False, hyperedge_labels=False, radius=0.05, + aspect="equal", **kwargs, ): """Draw hypergraphs displaying the hyperedges of order k>1 as convex hulls @@ -1273,6 +1282,11 @@ def draw_hypergraph_hull( pairs. By default, False. radius : float, optional Radius of the convex hull in the vicinity of the nodes, by default 0.05. + aspect : {"auto", "equal"} or float, optional + Set the aspect ratio of the axes scaling, i.e. y/x-scale. `aspect` is passed + directly to matplotlib's `ax.set_aspect()`. Default is `equal`. See full + description at + https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.set_aspect.html **kwargs : optional args Alternate default values. Values that can be overwritten are the following: * min_node_size @@ -1396,6 +1410,8 @@ def draw_hypergraph_hull( # compute axis limits _update_lims(pos, ax) + ax.set_aspect(aspect, "datalim") + return ax