@@ -1558,7 +1558,7 @@ def pprint_getters(self):
1558
1558
1559
1559
def getp (obj , property = None ):
1560
1560
"""
1561
- Return the value of an object 's *property*, or print all of them.
1561
+ Return the value of an `.Artist` 's *property*, or print all of them.
1562
1562
1563
1563
Parameters
1564
1564
----------
@@ -1579,6 +1579,10 @@ def getp(obj, property=None):
1579
1579
e.g.:
1580
1580
1581
1581
linewidth or lw = 2
1582
+
1583
+ See Also
1584
+ --------
1585
+ setp
1582
1586
"""
1583
1587
if property is None :
1584
1588
insp = ArtistInspector (obj )
@@ -1593,52 +1597,61 @@ def getp(obj, property=None):
1593
1597
1594
1598
def setp (obj , * args , file = None , ** kwargs ):
1595
1599
"""
1596
- Set a property on an artist object.
1600
+ Set one or more properties on an `.Artist`, or list allowed values.
1601
+
1602
+ Parameters
1603
+ ----------
1604
+ obj : `.Artist` or list of `.Artist`
1605
+ The artist(s) whose properties are being set or queried. When setting
1606
+ properties, all artists are affected; when querying the allowed values,
1607
+ only the first instance in the sequence is queried.
1597
1608
1598
- matplotlib supports the use of :func:`setp` ("set property") and
1599
- :func:`getp` to set and get object properties, as well as to do
1600
- introspection on the object. For example, to set the linestyle of a
1601
- line to be dashed, you can do::
1609
+ For example, two lines can be made thicker and red with a single call:
1602
1610
1603
- >>> line, = plot([1, 2, 3])
1604
- >>> setp(line, linestyle='--')
1611
+ >>> x = arange(0, 1, 0.01)
1612
+ >>> lines = plot(x, sin(2*pi*x), x, sin(4*pi*x))
1613
+ >>> setp(lines, linewidth=2, color='r')
1605
1614
1606
- If you want to know the valid types of arguments, you can provide
1607
- the name of the property you want to set without a value::
1615
+ file : file-like, default: `sys.stdout`
1616
+ Where `setp` writes its output when asked to list allowed values.
1608
1617
1609
- >>> setp(line, 'linestyle')
1610
- linestyle: {'-', '--', '-.', ':', '', (offset, on-off-seq), ...}
1618
+ >>> with open('output.log') as file:
1619
+ ... setp(line, file=file)
1620
+
1621
+ The default, ``None``, means `sys.stdout`.
1611
1622
1612
- If you want to see all the properties that can be set, and their
1613
- possible values, you can do: :
1623
+ *args, **kwargs
1624
+ The properties to set. The following combinations are supported :
1614
1625
1615
- >>> setp(line)
1616
- ... long output listing omitted
1626
+ - Set the linestyle of a line to be dashed:
1617
1627
1618
- By default `setp` prints to `sys.stdout`, but this can be modified using
1619
- the *file* keyword-only argument::
1628
+ >>> line, = plot([1, 2, 3])
1629
+ >>> setp(line, linestyle='--')
1630
+
1631
+ - Set multiple properties at once:
1632
+
1633
+ >>> setp(line, linewidth=2, color='r')
1634
+
1635
+ - List allowed values for a line's linestyle:
1636
+
1637
+ >>> setp(line, 'linestyle')
1638
+ linestyle: {'-', '--', '-.', ':', '', (offset, on-off-seq), ...}
1620
1639
1621
- >>> with fopen('output.log') as f:
1622
- >>> setp(line, file=f)
1640
+ - List all properties that can be set, and their allowed values:
1623
1641
1624
- :func:`setp` operates on a single instance or a iterable of
1625
- instances. If you are in query mode introspecting the possible
1626
- values, only the first instance in the sequence is used. When
1627
- actually setting values, all the instances will be set. e.g.,
1628
- suppose you have a list of two lines, the following will make both
1629
- lines thicker and red::
1642
+ >>> setp(line)
1643
+ agg_filter: a filter function, ...
1644
+ [long output listing omitted]
1630
1645
1631
- >>> x = arange(0, 1, 0.01)
1632
- >>> y1 = sin(2*pi*x)
1633
- >>> y2 = sin(4*pi*x)
1634
- >>> lines = plot(x, y1, x, y2)
1635
- >>> setp(lines, linewidth=2, color='r')
1646
+ `setp` also supports MATLAB style string/value pairs. For example, the
1647
+ following are equivalent:
1636
1648
1637
- :func:` setp` works with the MATLAB style string/value pairs or
1638
- with python kwargs. For example, the following are equivalent::
1649
+ >>> setp(lines, 'linewidth', 2, 'color', 'r') # MATLAB style
1650
+ >>> setp(lines, linewidth=2, color='r') # Python style
1639
1651
1640
- >>> setp(lines, 'linewidth', 2, 'color', 'r') # MATLAB style
1641
- >>> setp(lines, linewidth=2, color='r') # python style
1652
+ See Also
1653
+ --------
1654
+ getp
1642
1655
"""
1643
1656
1644
1657
if isinstance (obj , Artist ):
0 commit comments