Add a label near the point ``(x, y)``. Parameters ---------- x, y : float The approximate location of the label. inline : bool, default: True If *True* remove the segment of the contour beneath the label. inline_spacing : int,
(self, x, y, inline=True, inline_spacing=5,
transform=None)
| 443 | self.axes.add_artist(t) |
| 444 | |
| 445 | def add_label_near(self, x, y, inline=True, inline_spacing=5, |
| 446 | transform=None): |
| 447 | """ |
| 448 | Add a label near the point ``(x, y)``. |
| 449 | |
| 450 | Parameters |
| 451 | ---------- |
| 452 | x, y : float |
| 453 | The approximate location of the label. |
| 454 | inline : bool, default: True |
| 455 | If *True* remove the segment of the contour beneath the label. |
| 456 | inline_spacing : int, default: 5 |
| 457 | Space in pixels to leave on each side of label when placing |
| 458 | inline. This spacing will be exact for labels at locations where |
| 459 | the contour is straight, less so for labels on curved contours. |
| 460 | transform : `.Transform` or `False`, default: ``self.axes.transData`` |
| 461 | A transform applied to ``(x, y)`` before labeling. The default |
| 462 | causes ``(x, y)`` to be interpreted as data coordinates. `False` |
| 463 | is a synonym for `.IdentityTransform`; i.e. ``(x, y)`` should be |
| 464 | interpreted as display coordinates. |
| 465 | """ |
| 466 | |
| 467 | if transform is None: |
| 468 | transform = self.axes.transData |
| 469 | if transform: |
| 470 | x = self.axes.convert_xunits(x) |
| 471 | y = self.axes.convert_yunits(y) |
| 472 | x, y = transform.transform((x, y)) |
| 473 | |
| 474 | idx_level_min, idx_vtx_min, proj = self._find_nearest_contour( |
| 475 | (x, y), self.labelIndiceList) |
| 476 | path = self._paths[idx_level_min] |
| 477 | level = self.labelIndiceList.index(idx_level_min) |
| 478 | label_width = self._get_nth_label_width(level) |
| 479 | rotation, path = self._split_path_and_get_label_rotation( |
| 480 | path, idx_vtx_min, proj, label_width, inline_spacing) |
| 481 | self.add_label(*proj, rotation, self.labelLevelList[level], |
| 482 | self.labelCValueList[level]) |
| 483 | |
| 484 | if inline: |
| 485 | self._paths[idx_level_min] = path |
| 486 | |
| 487 | def pop_label(self, index=-1): |
| 488 | """Defaults to removing last label, but any index can be supplied""" |