|
19 | 19 | import numpy as np
|
20 | 20 | from numpy import ma
|
21 | 21 |
|
22 |
| -from matplotlib import _api, cbook, _docstring, font_manager |
| 22 | +from matplotlib import _api, cbook, _docstring |
23 | 23 | import matplotlib.artist as martist
|
24 | 24 | import matplotlib.collections as mcollections
|
25 | 25 | from matplotlib.patches import CirclePolygon
|
@@ -303,14 +303,11 @@ def __init__(self, Q, X, Y, U, label,
|
303 | 303 | self.labelcolor = labelcolor
|
304 | 304 | self.fontproperties = fontproperties or dict()
|
305 | 305 | self.kw = kwargs
|
306 |
| - _fp = self.fontproperties |
307 |
| - # boxprops = dict(facecolor='red') |
308 | 306 | self.text = mtext.Text(
|
309 |
| - text=label, # bbox=boxprops, |
| 307 | + text=label, |
310 | 308 | horizontalalignment=self.halign[self.labelpos],
|
311 | 309 | verticalalignment=self.valign[self.labelpos],
|
312 |
| - fontproperties=font_manager.FontProperties._from_any(_fp)) |
313 |
| - |
| 310 | + fontproperties=self.fontproperties) |
314 | 311 | if self.labelcolor is not None:
|
315 | 312 | self.text.set_color(self.labelcolor)
|
316 | 313 | self._dpi_at_last_init = None
|
@@ -347,29 +344,20 @@ def _init(self):
|
347 | 344 | self.vector.set_figure(self.get_figure())
|
348 | 345 | self._dpi_at_last_init = self.Q.axes.figure.dpi
|
349 | 346 |
|
350 |
| - def _text_x(self, x): |
351 |
| - if self.labelpos == 'E': |
352 |
| - return x + self.labelsep |
353 |
| - elif self.labelpos == 'W': |
354 |
| - return x - self.labelsep |
355 |
| - else: |
356 |
| - return x |
357 |
| - |
358 |
| - def _text_y(self, y): |
359 |
| - if self.labelpos == 'N': |
360 |
| - return y + self.labelsep |
361 |
| - elif self.labelpos == 'S': |
362 |
| - return y - self.labelsep |
363 |
| - else: |
364 |
| - return y |
| 347 | + def _text_shift(self): |
| 348 | + return { |
| 349 | + "N": (0, +self.labelsep), |
| 350 | + "S": (0, -self.labelsep), |
| 351 | + "E": (+self.labelsep, 0), |
| 352 | + "W": (-self.labelsep, 0), |
| 353 | + }[self.labelpos] |
365 | 354 |
|
366 | 355 | @martist.allow_rasterization
|
367 | 356 | def draw(self, renderer):
|
368 | 357 | self._init()
|
369 | 358 | self.vector.draw(renderer)
|
370 |
| - x, y = self.get_transform().transform((self.X, self.Y)) |
371 |
| - self.text.set_x(self._text_x(x)) |
372 |
| - self.text.set_y(self._text_y(y)) |
| 359 | + pos = self.get_transform().transform((self.X, self.Y)) |
| 360 | + self.text.set_position(pos + self._text_shift()) |
373 | 361 | self.text.draw(renderer)
|
374 | 362 | self.stale = False
|
375 | 363 |
|
|
0 commit comments