@@ -1474,39 +1474,34 @@ def pprint_getters(self):
1474
1474
1475
1475
def getp (obj , property = None ):
1476
1476
"""
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.
1479
1478
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`.
1488
1483
1489
- obj.get_somename()
1484
+ property : str or None, default: None
1485
+ If the *property* is 'somename', this function returns
1486
+ ``obj.get_somename()``.
1490
1487
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:
1495
1492
1496
- property or alias = value
1493
+ property or alias = value
1497
1494
1498
- e.g.:
1495
+ e.g.:
1499
1496
1500
- linewidth or lw = 2
1497
+ linewidth or lw = 2
1501
1498
"""
1502
1499
if property is None :
1503
1500
insp = ArtistInspector (obj )
1504
1501
ret = insp .pprint_getters ()
1505
1502
print ('\n ' .join (ret ))
1506
1503
return
1507
-
1508
- func = getattr (obj , 'get_' + property )
1509
- return func ()
1504
+ return getattr (obj , 'get_' + property )()
1510
1505
1511
1506
# alias
1512
1507
get = getp
0 commit comments