An arrow patch.
| 1417 | |
| 1418 | # COVERAGE NOTE: Not used internally or from examples |
| 1419 | class Arrow(Patch): |
| 1420 | """An arrow patch.""" |
| 1421 | |
| 1422 | def __str__(self): |
| 1423 | return "Arrow()" |
| 1424 | |
| 1425 | _path = Path._create_closed([ |
| 1426 | [0.0, 0.1], [0.0, -0.1], [0.8, -0.1], [0.8, -0.3], [1.0, 0.0], |
| 1427 | [0.8, 0.3], [0.8, 0.1]]) |
| 1428 | |
| 1429 | @_docstring.interpd |
| 1430 | def __init__(self, x, y, dx, dy, *, width=1.0, **kwargs): |
| 1431 | """ |
| 1432 | Draws an arrow from (*x*, *y*) to (*x* + *dx*, *y* + *dy*). |
| 1433 | The width of the arrow is scaled by *width*. |
| 1434 | |
| 1435 | Parameters |
| 1436 | ---------- |
| 1437 | x : float |
| 1438 | x coordinate of the arrow tail. |
| 1439 | y : float |
| 1440 | y coordinate of the arrow tail. |
| 1441 | dx : float |
| 1442 | Arrow length in the x direction. |
| 1443 | dy : float |
| 1444 | Arrow length in the y direction. |
| 1445 | width : float, default: 1 |
| 1446 | Scale factor for the width of the arrow. With a default value of 1, |
| 1447 | the tail width is 0.2 and head width is 0.6. |
| 1448 | **kwargs |
| 1449 | Keyword arguments control the `Patch` properties: |
| 1450 | |
| 1451 | %(Patch:kwdoc)s |
| 1452 | |
| 1453 | See Also |
| 1454 | -------- |
| 1455 | FancyArrow |
| 1456 | Patch that allows independent control of the head and tail |
| 1457 | properties. |
| 1458 | """ |
| 1459 | super().__init__(**kwargs) |
| 1460 | self.set_data(x, y, dx, dy, width) |
| 1461 | |
| 1462 | def get_path(self): |
| 1463 | return self._path |
| 1464 | |
| 1465 | def get_patch_transform(self): |
| 1466 | return self._patch_transform |
| 1467 | |
| 1468 | def set_data(self, x=None, y=None, dx=None, dy=None, width=None): |
| 1469 | """ |
| 1470 | Set `.Arrow` x, y, dx, dy and width. |
| 1471 | Values left as None will not be updated. |
| 1472 | |
| 1473 | Parameters |
| 1474 | ---------- |
| 1475 | x, y : float or None, default: None |
| 1476 | The x and y coordinates of the arrow base. |
nothing calls this directly
no test coverage detected
searching dependent graphs…