8000 numpydocify quiverkey. · matplotlib/matplotlib@cabc053 · GitHub
[go: up one dir, main page]

Skip to content

Commit cabc053

Browse files
committed
numpydocify quiverkey.
1 parent dd18211 commit cabc053

File tree

5 files changed

+80
-71
lines changed

5 files changed

+80
-71
lines changed

doc/api/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ Modules
5555
patheffects_api.rst
5656
pyplot_summary.rst
5757
projections_api.rst
58+
quiver_api.rst
5859
rcsetup_api.rst
5960
sankey_api.rst
6061
scale_api.rst
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Deprecations
2+
````````````
3+
4+
``quiver.QuiverKey.quiverkey_doc`` is deprecated; use
5+
``quiver.QuiverKey.__init__.__doc__`` instead.

doc/api/quiver_api.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
*********************
2+
``matplotlib.quiver``
3+
*********************
4+
5+
.. currentmodule:: matplotlib.quiver
6+
7+
.. automodule:: matplotlib.quiver
8+
:no-members:
9+
:no-inherited-members:
10+
11+
Classes
12+
-------
13+
14+
.. autosummary::
15+
:toctree: _as_gen/
16+
:template: autosummary.rst
17+
18+
Quiver
19+
QuiverKey
20+
Barbs

lib/matplotlib/axes/_axes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4991,11 +4991,11 @@ def arrow(self, x, y, dx, dy, **kwargs):
49914991
self.add_artist(a)
49924992
return a
49934993

4994+
@docstring.copy(mquiver.QuiverKey.__init__)
49944995
def quiverkey(self, Q, X, Y, U, label, **kw):
49954996
qk = mquiver.QuiverKey(Q, X, Y, U, label, **kw)
49964997
self.add_artist(qk)
49974998
return qk
4998-
quiverkey.__doc__ = mquiver.QuiverKey.quiverkey_doc
49994999

50005000
# Handle units for x and y, if they've been passed
50015001
def _quiver_units(self, args, kw):

lib/matplotlib/quiver.py

Lines changed: 53 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -163,74 +163,9 @@
163163
quiverkey : Add a key to a quiver plot
164164
""" % docstring.interpd.params
165165

166-
_quiverkey_doc = """
167-
Add a key to a quiver plot.
168-
169-
Call signature::
170-
171-
quiverkey(Q, X, Y, U, label, **kw)
172-
173-
Arguments:
174-
175-
*Q*:
176-
The Quiver instance returned by a call to quiver.
177-
178-
*X*, *Y*:
179-
The location of the key; additional explanation follows.
180-
181-
*U*:
182-
The length of the key
183-
184-
*label*:
185-
A string with the length and units of the key
186-
187-
Keyword arguments:
188-
189-
*angle* = 0
190-
The angle of the key arrow. Measured in degrees anti-clockwise from the
191-
x-axis.
192-
193-
*coordinates* = [ 'axes' | 'figure' | 'data' | 'inches' ]
194-
Coordinate system and units for *X*, *Y*: 'axes' and 'figure' are
195-
normalized coordinate systems with 0,0 in the lower left and 1,1
196-
in the upper right; 'data' are the axes data coordinates (used for
197-
the locations of the vectors in the quiver plot itself); 'inches'
198-
is position in the figure in inches, with 0,0 at the lower left
199-
corner.
200-
201-
*color*:
202-
overrides face and edge colors from *Q*.
203-
204-
*labelpos* = [ 'N' | 'S' | 'E' | 'W' ]
205-
Position the label above, below, to the right, to the left of the
206-
arrow, respectively.
207-
208-
*labelsep*:
209-
Distance in inches between the arrow and the label. Default is
210-
0.1
211-
212-
*labelcolor*:
213-
defaults to default :class:`~matplotlib.text.Text` color.
214-
215-
*fontproperties*:
216-
A dictionary with keyword arguments accepted by the
217-
:class:`~matplotlib.font_manager.FontProperties` initializer:
218-
*family*, *style*, *variant*, *size*, *weight*
219-
220-
Any additional keyword arguments are used to override vector
221-
properties taken from *Q*.
222-
223-
The positioning of the key depends on *X*, *Y*, *coordinates*, and
224-
*labelpos*. If *labelpos* is 'N' or 'S', *X*, *Y* give the position
225-
of the middle of the key arrow. If *labelpos* is 'E', *X*, *Y*
226-
positions the head, and if *labelpos* is 'W', *X*, *Y* positions the
227-
tail; in either of these two cases, *X*, *Y* is somewhere in the
228-
middle of the arrow+label key object.
229-
"""
230-
231166

232167
class QuiverKey(martist.Artist):
233-
""" Labelled arrow for use as a quiver plot scale key."""
168+
"""Labelled arrow for use as a quiver plot scale key."""
234169
halign = {'N': 'center', 'S': 'center', 'E': 'left', 'W': 'right'}
235170
valign = {'N': 'bottom', 'S': 'top', 'E': 'center', 'W': 'center'}
236171
pivot = {'N': 'middle', 'S': 'middle', 'E': 'tip', 'W': 'tail'}
@@ -239,6 +174,53 @@ def __init__(self, Q, X, Y, U, label,
239174
*, angle=0, coordinates='axes', color=None, labelsep=0.1,
240175
labelpos='N', labelcolor=None, fontproperties=None,
241176
**kw):
177+
"""
178+
Add a key to a quiver plot.
179+
180+
The positioning of the key depends on *X*, *Y*, *coordinates*, and
181+
*labelpos*. If *labelpos* is 'N' or 'S', *X*, *Y* give the position of
182+
the middle of the key arrow. If *labelpos* is 'E', *X*, *Y* positions
183+
the head, and if *labelpos* is 'W', *X*, *Y* positions the tail; in
184+
either of these two cases, *X*, *Y* is somewhere in the middle of the
185+
arrow+label key object.
186+
187+
Parameters
188+
----------
189+
Q : `Quiver`
190+
A `Quiver` object as returned by a call to `~Axes.quiver()`.
191+
X, Y: float
192+
The location of the key.
193+
U : float
194+
The length of the key
195+
label : str
196+
The key label (e.g., length and units of the key).
197+
angle : float, default: 0
198+
The angle of the key arrow, in degrees anti-clockwise from the
199+
x-axis.
200+
coordinates : {'axes', 'figure', 'data', 'inches'}, default: 'axes'
201+
Coordinate system and units for *X*, *Y*: 'axes' and 'figure' are
202+
normalized coordinate systems with 0,0 in the lower left and 1,1
203+
in the upper right; 'data' are the axes data coordinates (used for
204+
the locations of the vectors in the quiver plot itself); 'inches'
205+
is position in the figure in inches, with 0,0 at the lower left
206+
corner.
207+
color : color
208+
Overrides face and edge colors from *Q*.
209+
labelpos : {'N', 'S', 'E', 'W'}
210+
Position the label above, below, to the right, to the left of the
211+
arrow, respectively.
212+
labelsep : float, default: 0.1
213+
Distance in inches between the arrow and the label.
214+
labelcolor : color, default: :rc:`text.color`
215+
Label color.
216+
fontproperties : dict, optional
217+
A dictionary with keyword arguments accepted by the
218+
`~matplotlib.font_manager.FontProperties` initializer:
219+
*family*, *style*, *variant*, *size*, *weight*
220+
**kwargs
221+
Any additional keyword arguments are used to override vector
222+
properties taken from *Q*.
223+
"""
242224
martist.Artist.__init__(self)
243225
self.Q = Q
244226
self.X = X
@@ -292,8 +274,6 @@ def remove(self):
292274
# pass the remove call up the stack
293275
martist.Artist.remove(self)
294276

295-
__init__.__doc__ = _quiverkey_doc
296-
297277
def _init(self):
298278
if True: # not self._initialized:
299279
if not self.Q._initialized:
@@ -374,7 +354,10 @@ def contains(self, mouseevent):
374354
return True, {}
375355
return False, {}
376356

377-
quiverkey_doc = _quiverkey_doc
357+
@cbook.deprecated("3.2")
358+
@property
359+
def quiverkey_doc(self):
360+
return self.__init__.__doc__
378361

379362

380363
# This is a helper function that parses out the various combination of
@@ -690,7 +673,7 @@ def _make_verts(self, U, V, angles):
690673
return XY
691674

692675
def _h_arrows(self, length):
693-
""" length is in arrow width units """
676+
"""Length is in arrow width units."""
694677
# It might be possible to streamline the code
695678
# and speed it up a bit by using complex (x,y)
696679
# instead of separate arrays; but any gain would be slight.

0 commit comments

Comments
 (0)
0