MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / labels

Method labels

lib/matplotlib/contour.py:493–518  ·  view source on GitHub ↗
(self, inline, inline_spacing)

Source from the content-addressed store, hash-verified

491 t.remove()
492
493 def labels(self, inline, inline_spacing):
494 for idx, (icon, lev, cvalue) in enumerate(zip(
495 self.labelIndiceList,
496 self.labelLevelList,
497 self.labelCValueList,
498 )):
499 trans = self.get_transform()
500 label_width = self._get_nth_label_width(idx)
501 additions = []
502 for subpath in self._paths[icon]._iter_connected_components():
503 screen_xys = trans.transform(subpath.vertices)
504 # Check if long enough for a label
505 if self.print_label(screen_xys, label_width):
506 x, y, idx = self.locate_label(screen_xys, label_width)
507 rotation, path = self._split_path_and_get_label_rotation(
508 subpath, idx, (x, y),
509 label_width, inline_spacing)
510 self.add_label(x, y, rotation, lev, cvalue) # Really add label.
511 if inline: # If inline, add new contours
512 additions.append(path)
513 else: # If not adding label, keep old path
514 additions.append(subpath)
515 # After looping over all segments on a contour, replace old path by new one
516 # if inlining.
517 if inline:
518 self._paths[icon] = Path.make_compound_path(*additions)
519
520 def remove(self):
521 super().remove()

Callers 1

clabelMethod · 0.95

Calls 9

_get_nth_label_widthMethod · 0.95
print_labelMethod · 0.95
locate_labelMethod · 0.95
add_labelMethod · 0.95
make_compound_pathMethod · 0.80
get_transformMethod · 0.45
transformMethod · 0.45

Tested by

no test coverage detected