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

Skip to content

Commit c57a41c

Browse files
committed
Numpydocify artist.getp().
1 parent 860803d commit c57a41c

File tree

1 file changed

+16
-21
lines changed

1 file changed

+16
-21
lines changed

lib/matplotlib/artist.py

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1474,39 +1474,34 @@ def pprint_getters(self):
14741474

14751475
def getp(obj, property=None):
14761476
"""
1477-
Return the value of object's property. *property* is an optional string
1478-
for the property you want to return
1477+
Return the value of an object's *property*, or print all of them.
14791478
1480-
Example usage::
1481-
1482-
getp(obj) # get all the object properties
1483-
getp(obj, 'linestyle') # get the linestyle property
1484-
1485-
*obj* is a `.Artist` instance, e.g., `~matplotlib.lines.Line2D` or an
1486-
instance of a `~matplotlib.axes.Axes` or `matplotlib.text.Text`.
1487-
If the *property* is 'somename', this function returns
1479+
Parameters
1480+
----------
1481+
obj : `.Artist`
1482+
The queried artist; e.g., a `.Line2D`, a `.Text`, or an `~.axes.Axes`.
14881483
1489-
obj.get_somename()
1484+
property : str or None, default: None
1485+
If the *property* is 'somename', this function returns
1486+
``obj.get_somename()``.
14901487
1491-
:func:`getp` can be used to query all the gettable properties with
1492-
``getp(obj)``. Many properties have aliases for shorter typing, e.g.
1493-
'lw' is an alias for 'linewidth'. In the output, aliases and full
1494-
property names will be listed as:
1488+
If is is None (or unset), it *prints* all gettable properties from
1489+
*obj*. Many properties have aliases for shorter typing, e.g. 'lw' is
1490+
an alias for 'linewidth'. In the output, aliases and full property
1491+
names will be listed as:
14951492
1496-
property or alias = value
1493+
property or alias = value
14971494
1498-
e.g.:
1495+
e.g.:
14991496
1500-
linewidth or lw = 2
1497+
linewidth or lw = 2
15011498
"""
15021499
if property is None:
15031500
insp = ArtistInspector(obj)
15041501
ret = insp.pprint_getters()
15051502
print('\n'.join(ret))
15061503
return
1507-
1508-
func = getattr(obj, 'get_' + property)
1509-
return func()
1504+
return getattr(obj, 'get_' + property)()
15101505

15111506
# alias
15121507
get = getp

0 commit comments

Comments
 (0)