|
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,13 +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 | 306 | self.text = mtext.Text( |
308 | 307 | text=label, |
309 | 308 | horizontalalignment=self.halign[self.labelpos], |
310 | 309 | verticalalignment=self.valign[self.labelpos], |
311 | | - fontproperties=font_manager.FontProperties._from_any(_fp)) |
312 | | - |
| 310 | + fontproperties=self.fontproperties) |
313 | 311 | if self.labelcolor is not None: |
314 | 312 | self.text.set_color(self.labelcolor) |
315 | 313 | self._dpi_at_last_init = None |
@@ -346,29 +344,20 @@ def _init(self): |
346 | 344 | self.vector.set_figure(self.get_figure()) |
347 | 345 | self._dpi_at_last_init = self.Q.axes.figure.dpi |
348 | 346 |
|
349 | | - def _text_x(self, x): |
350 | | - if self.labelpos == 'E': |
351 | | - return x + self.labelsep |
352 | | - elif self.labelpos == 'W': |
353 | | - return x - self.labelsep |
354 | | - else: |
355 | | - return x |
356 | | - |
357 | | - def _text_y(self, y): |
358 | | - if self.labelpos == 'N': |
359 | | - return y + self.labelsep |
360 | | - elif self.labelpos == 'S': |
361 | | - return y - self.labelsep |
362 | | - else: |
363 | | - 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] |
364 | 354 |
|
365 | 355 | @martist.allow_rasterization |
366 | 356 | def draw(self, renderer): |
367 | 357 | self._init() |
368 | 358 | self.vector.draw(renderer) |
369 | | - x, y = self.get_transform().transform((self.X, self.Y)) |
370 | | - self.text.set_x(self._text_x(x)) |
371 | | - 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()) |
372 | 361 | self.text.draw(renderer) |
373 | 362 | self.stale = False |
374 | 363 |
|
|
0 commit comments