Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enforce equal aspect for circular layout #430 #432

Merged
merged 2 commits into from
Jul 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading