@@ -401,11 +401,50 @@ def plot_box(
401
401
return r
402
402
403
403
def plot_arrow (start , end , ax = None , ** kwargs ):
404
+ """
405
+ Plot 2D arrow
406
+
407
+ :param start: start point, arrow tail
408
+ :type start: array_like(2)
409
+ :param end: end point, arrow head
410
+ :type end: array_like(2)
411
+ :param ax: axes to draw into, defaults to None
412
+ :type ax: Axes, optional
413
+ :param kwargs: argumetns to pass to :class:`matplotlib.patches.Arrow`
414
+
415
+ Example:
416
+
417
+ .. runblock:: pycon
418
+
419
+ >>> from spatialmath.base import plotvol2, plot_arrow
420
+ >>> plotvol2(5)
421
+ >>> plot_arrow((-2, 2), (3, 4), color='r', width=0.1) # red arrow
422
+ """
404
423
ax = axes_logic (ax , 2 )
405
424
406
425
ax .arrow (start [0 ], start [1 ], end [0 ] - start [0 ], end [1 ] - start [1 ], length_includes_head = True , ** kwargs )
407
426
408
427
def plot_polygon (vertices , * fmt , close = False , ** kwargs ):
428
+ """
429
+ Plot polygon
430
+
431
+ :param vertices: vertices
432
+ :type vertices: ndarray(2,N)
433
+ :param close: close the polygon, defaults to False
434
+ :type close: bool, optional
435
+ :param kwargs: arguments passed to Patch
436
+ :return: Matplotlib artist
437
+ :rtype: line or patch
438
+
439
+ Example:
440
+
441
+ .. runblock:: pycon
442
+
443
+ >>> from spatialmath.base import plotvol2, plot_polygon
444
+ >>> plotvol2(5)
445
+ >>> vertices = np.array([[-1, 2, -1], [1, 0, -1]])
446
+ >>> plot_polygon(vertices, filled=True, facecolor='g') # green filled triangle
447
+ """
409
448
410
449
if close :
411
450
vertices = np .hstack ((vertices , vertices [:, [0 ]]))
@@ -471,7 +510,7 @@ def plot_circle(
471
510
:param args:
472
511
:param radius: radius of circle
473
512
:type radius: float
474
- :param resolution: number of points on circumferece , defaults to 50
513
+ :param resolution: number of points on circumference , defaults to 50
475
514
:type resolution: int, optional
476
515
:return: the matplotlib object
477
516
:rtype: list of Line2D or Patch.Polygon
@@ -1168,17 +1207,13 @@ def plotvol2(dim, ax=None, equal=True, grid=False, labels=True):
1168
1207
1169
1208
Initialize axes with dimensions given by ``dim`` which can be:
1170
1209
1171
- * A (scalar), -A:A x -A:A
1172
- * [A,B], A:B x A:B
1173
- * [A,B,C,D], A:B x C:D
1174
-
1175
- ================== ====== ======
1176
- input xrange yrange
1177
- ================== ====== ======
1178
- A (scalar) -A:A -A:A
1179
- [A, B] A:B A:B
1180
- [A, B, C, D, E, F] A:B C:D
1181
- ================== ====== ======
1210
+ ============== ====== ======
1211
+ input xrange yrange
1212
+ ============== ====== ======
1213
+ A (scalar) -A:A -A:A
1214
+ [A, B] A:B A:B
1215
+ [A, B, C, D] A:B C:D
1216
+ ============== ====== ======
1182
1217
1183
1218
:seealso: :func:`plotvol3`, :func:`expand_dims`
1184
1219
"""
@@ -1259,7 +1294,7 @@ def plotvol3(
1259
1294
1260
1295
def expand_dims (dim = None , nd = 2 ):
1261
1296
"""
1262
- Expact compact axis dimensions
1297
+ Expand compact axis dimensions
1263
1298
1264
1299
:param dim: dimensions, defaults to None
1265
1300
:type dim: scalar, array_like(2), array_like(4), array_like(6), optional
0 commit comments