8000 move the test for matplotlib being installed into axes_logic · VB6Hobbyst7/spatialmath-python@0ab20ec · GitHub
[go: up one dir, main page]

Skip to content

Commit 0ab20ec

Browse files
committed
move the test for matplotlib being installed into axes_logic
1 parent d2e167a commit 0ab20ec

File tree

3 files changed

+322
-272
lines changed

3 files changed

+322
-272
lines changed

spatialmath/base/graphics.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,21 @@
44
import numpy as np
55
import scipy as sp
66
from scipy.stats.distributions import chi2
7-
import matplotlib.pyplot as plt
8-
from matplotlib.patches import Circle
9-
from mpl_toolkits.mplot3d.art3d import (
10-
Poly3DCollection,
11-
Line3DCollection,
12-
pathpatch_2d_to_3d,
13-
)
7+
148
from spatialmath import base
159

10+
try:
11+
import matplotlib.pyplot as plt
12+
from matplotlib.patches import Circle
13+
from mpl_toolkits.mplot3d.art3d import (
14+
Poly3DCollection,
15+
Line3DCollection,
16+
pathpatch_2d_to_3d,
17+
)
18+
_matplotlib_exists = True
19+
except ImportError: # pragma: no cover
20+
_matplotlib_exists = False
21+
1622
"""
1723
Set of functions to draw 2D and 3D graphical primitives using matplotlib.
1824
@@ -955,6 +961,10 @@ def axes_logic(ax, dimensions, projection="ortho"):
955961
956962
Used by all plot_xxx() functions in this module.
957963
"""
964+
965+
if not _matplotlib_exists:
966+
raise NotImplementedError("Matplotlib is not installed: pip install matplotlib")
967+
958968
# print(f"new axis logic ({dimensions}D): ", end='')
959969
if ax is None:
960970
# no axes passed in, find out what's happening

0 commit comments

Comments
 (0)
0