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

Method add_label

lib/matplotlib/contour.py:423–443  ·  view source on GitHub ↗

Add a contour label, respecting whether *use_clabeltext* was set.

(self, x, y, rotation, lev, cvalue)

Source from the content-addressed store, hash-verified

421 return angle, Path(xys, codes)
422
423 def add_label(self, x, y, rotation, lev, cvalue):
424 """Add a contour label, respecting whether *use_clabeltext* was set."""
425 data_x, data_y = self.axes.transData.inverted().transform((x, y))
426 t = Text(
427 data_x, data_y,
428 text=self.get_text(lev, self.labelFmt),
429 rotation=rotation,
430 horizontalalignment='center', verticalalignment='center',
431 zorder=self._clabel_zorder,
432 color=self.labelMappable.to_rgba(cvalue, alpha=self.get_alpha()),
433 fontproperties=self._label_font_props,
434 clip_box=self.axes.bbox)
435 if self._use_clabeltext:
436 data_rotation, = self.axes.transData.inverted().transform_angles(
437 [rotation], [[x, y]])
438 t.set(rotation=data_rotation, transform_rotates_text=True)
439 self.labelTexts.append(t)
440 self.labelCValues.append(cvalue)
441 self.labelXYs.append((x, y))
442 # Add label to plot here - useful for manual mode label selection
443 self.axes.add_artist(t)
444
445 def add_label_near(self, x, y, inline=True, inline_spacing=5,
446 transform=None):

Callers 2

add_label_nearMethod · 0.95
labelsMethod · 0.95

Calls 9

get_textMethod · 0.95
TextClass · 0.90
transform_anglesMethod · 0.80
transformMethod · 0.45
invertedMethod · 0.45
to_rgbaMethod · 0.45
get_alphaMethod · 0.45
setMethod · 0.45
add_artistMethod · 0.45

Tested by

no test coverage detected