8000 create dummy versions of trplot functions if matplotlib not installed · RPellowski/spatialmath-python@149f734 · GitHub
[go: up one dir, main page]

Skip to content

Commit 149f734

Browse files
committed
create dummy versions of trplot functions if matplotlib not installed
1 parent d396046 commit 149f734

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

spatialmath/base/transforms2d.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ def trplot2(T, ax=None, dims=None, color='blue', frame=None, textcolor=None, lab
429429
ax.quiver(o[0], o[1], x[0]-o[0], x[1]-o[1], angles='xy', scale_units='xy', scale=1, linewidth=width, facecolor=color, edgecolor=color)
430430
ax.quiver(o[0], o[1], y[0]-o[0], y[1]-o[1], angles='xy', scale_units='xy', scale=1, linewidth=width, facecolor=color, edgecolor=color)
431431
# plot an invisible point at the end of each arrow to allow auto-scaling to work
432-
ax.scatter( x=[o[0], x[0], y[0]], y=[o[1], x[1], y[1]], s=[20,0,0,0])
432+
ax.scatter( x=[o[0], x[0], y[0]], y=[o[1], x[1], y[1]], s=[20,0,0])
433433
else:
434434
ax.plot([o[0], x[0]], [o[1], x[1]], color=color, linewidth=width)
435435
ax.plot([o[0], y[0]], [o[1], y[1]], color=color, linewidth=width)
@@ -450,8 +450,10 @@ def trplot2(T, ax=None, dims=None, color='blue', frame=None, textcolor=None, lab
450450

451451
ax.text(x[0], x[1], "$%c_{%s}$" % (labels[0],frame), color=color, horizontalalignment='center', verticalalignment='center')
452452
ax.text(y[0], y[1], "$%c_{%s}$" % (labels[1], frame), color=color, horizontalalignment='center', verticalalignment='center')
453-
except:
454-
pass
453+
454+
except: # pragma: no cover
455+
def trplot2(*args, **kwargs):
456+
print('** trplot2: no plot produced -- matplotlib not installed')
455457

456458
if __name__ == '__main__': # pragma: no cover
457459
import pathlib

spatialmath/base/transforms3d.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,8 +1249,10 @@ def trplot(T, axes=None, dims=None, color='blue', frame=None, textcolor=None, la
12491249
ax.text(x[0], x[1], x[2], "$%c_{%s}$" % (labels[0],frame), color=color, horizontalalignment='center', verticalalignment='center')
12501250
ax.text(y[0], y[1], y[2], "$%c_{%s}$" % (labels[1], frame), color=color, horizontalalignment='center', verticalalignment='center')
12511251
ax.text(z[0], z[1], z[2], "$%c_{%s}$" % (labels[2], frame), color=color, horizontalalignment='center', verticalalignment='center')
1252-
except:
1253-
pass
1252+
1253+
except: # pragma: no cover
1254+
def trplot(*args, **kwargs):
1255+
print('** trplot: no plot produced -- matplotlib not installed')
12541256

12551257
if __name__ == '__main__': # pragma: no cover
12561258
import pathlib

0 commit comments

Comments
 (0)
0