Add a contour label, respecting whether *use_clabeltext* was set.
(self, x, y, rotation, lev, cvalue)
| 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): |
no test coverage detected