Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit de6fe07

Browse files
authored
Merge pull request #22449 from anntzer/q
Small cleanup to quiver.
2 parents 0a8b637 + d7de77e commit de6fe07

File tree

1 file changed

+13
-27
lines changed

1 file changed

+13
-27
lines changed

lib/matplotlib/quiver.py

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
arrow more pointed, reduce *headwidth* or increase *headlength* and
5656
*headaxislength*. To make the head smaller relative to the shaft,
5757
scale down all the head parameters. You will probably do best to leave
58-
minshaft alone.
58+
*minshaft* alone.
5959
6060
**Arrow outline**
6161
@@ -595,32 +595,18 @@ def set_UVC(self, U, V, C=None):
595595
self.stale = True
596596

597597
def _dots_per_unit(self, units):
598-
"""
599-
Return a scale factor for converting from units to pixels
600-
"""
601-
if units in ('x', 'y', 'xy'):
602-
if units == 'x':
603-
dx0 = self.axes.viewLim.width
604-
dx1 = self.axes.bbox.width
605-
elif units == 'y':
606-
dx0 = self.axes.viewLim.height
607-
dx1 = self.axes.bbox.height
608-
else: # 'xy', i.e. hypot(x, y)
609-
dx0 = np.hypot(*self.axes.viewLim.size)
610-
dx1 = np.hypot(*self.axes.bbox.size)
611-
dx = dx1 / dx0
612-
else:
613-
if units == 'width':
614-
dx = self.axes.bbox.width
615-
elif units == 'height':
616-
dx = self.axes.bbox.height
617-
elif units == 'dots':
618-
dx = 1.0
619-
elif units == 'inches':
620-
dx = self.axes.figure.dpi
621-
else:
622-
raise ValueError('unrecognized units')
623-
return dx
598+
"""Return a scale factor for converting from units to pixels."""
599+
bb = self.axes.bbox
600+
vl = self.axes.viewLim
601+
return _api.check_getitem({
602+
'x': bb.width / vl.width,
603+
'y': bb.height / vl.height,
604+
'xy': np.hypot(*bb.size) / np.hypot(*vl.size),
605+
'width': bb.width,
606+
'height': bb.height,
607+
'dots': 1.,
608+
'inches': self.axes.figure.dpi,
609+
}, units=units)
624610

625611
def _set_transform(self):
626612
"""

0 commit comments

Comments
 (0)