X Tutup
Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions lib/matplotlib/quiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,9 @@
A dictionary with keyword arguments accepted by the
:class:`~matplotlib.font_manager.FontProperties` initializer:
*family*, *style*, *variant*, *size*, *weight*

*vswap*:
Swap the horizontal key to a vertical key

Any additional keyword arguments are used to override vector
properties taken from *Q*.
Expand Down Expand Up @@ -240,6 +243,8 @@ def __init__(self, Q, X, Y, U, label, **kw):
self.color = kw.pop('color', None)
self.label = label
self._labelsep_inches = kw.pop('labelsep', 0.1)
self._vswap = kw.pop('vswap', False)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use pop, add it as a kwarg in the call signature.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And where you are at it can you move the rest of the things that use pop up into the signature?

vswap = {True: 'vertical', False: 0}
self.labelsep = (self._labelsep_inches * Q.ax.figure.dpi)

# try to prevent closure over the real self
Expand Down Expand Up @@ -267,6 +272,7 @@ def on_dpi_change(fig):
text=label, # bbox=boxprops,
horizontalalignment=self.halign[self.labelpos],
verticalalignment=self.valign[self.labelpos],
rotation=vswap[self._vswap],
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be

rotation='vertical' if self._vswap else 'horizontal',

fontproperties=font_manager.FontProperties(**_fp))

if self.labelcolor is not None:
Expand Down Expand Up @@ -295,8 +301,12 @@ def _init(self):
# Hack: save and restore the Umask
_mask = self.Q.Umask
self.Q.Umask = ma.nomask
self.verts = self.Q._make_verts(np.array([self.U]),
np.zeros((1,)))
if self._vswap:
self.verts = self.Q._make_verts(np.zeros((1,)),
np.array([self.U]))
else:
self.verts = self.Q._make_verts(np.array([self.U]),
np.zeros((1,)))
self.Q.Umask = _mask
self.Q.pivot = _pivot
kw = self.Q.polykw
Expand Down
X Tutup