Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 8 additions & 0 deletions ultraplot/axes/three.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,11 @@ def __init__(self, *args, **kwargs):

kwargs.setdefault("alpha", 0.0)
super().__init__(*args, **kwargs)

def graph(self, *args, **kwargs):
"""
Draw network graphs on 3D projections.
"""
from .plot import PlotAxes

return PlotAxes.graph(self, *args, **kwargs)
16 changes: 16 additions & 0 deletions ultraplot/tests/test_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,22 @@ def test_graph_input():
ax.graph("invalid_input")


def test_graph_on_3d_projection():
"""
Ensure graph plotting is available on 3D axes.
"""
import networkx as nx

g = nx.path_graph(5)
_, axs = uplt.subplots(proj="3d")
ax = axs[0]
nodes, edges, labels = ax.graph(g)
assert callable(getattr(ax, "graph", None))
assert nodes is not False
assert edges is not False
assert labels is False


def test_graph_layout_input():
"""
Test if layout is in a [0, 1] x [0, 1] box
Expand Down