Skip to content

Commit

Permalink
feat: enforce equal aspect for circular layout #430 (#432)
Browse files Browse the repository at this point in the history
* feat: enforce equal aspect for circular layout #430

* changed implementation of set_aspect
  • Loading branch information
maximelucas authored Jul 27, 2023
1 parent 059b9c9 commit cbaec09
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions xgi/drawing/draw.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def draw(
max_order=None,
node_labels=False,
hyperedge_labels=False,
aspect="equal",
**kwargs,
):
"""Draw hypergraph or simplicial complex.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -216,6 +222,8 @@ def draw(
# compute axis limits
_update_lims(pos, ax)

ax.set_aspect(aspect, "datalim")

return ax


Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1396,6 +1410,8 @@ def draw_hypergraph_hull(
# compute axis limits
_update_lims(pos, ax)

ax.set_aspect(aspect, "datalim")

return ax


Expand Down

0 comments on commit cbaec09

Please sign in to comment.