Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 242ebd7

Browse filesBrowse files
committed
Numpydocify setp.
1 parent 327cfcf commit 242ebd7
Copy full SHA for 242ebd7

File tree

Expand file treeCollapse file tree

1 file changed

+46
-35
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+46
-35
lines changed

‎lib/matplotlib/artist.py

Copy file name to clipboardExpand all lines: lib/matplotlib/artist.py
+46-35Lines changed: 46 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1558,7 +1558,7 @@ def pprint_getters(self):
15581558

15591559
def getp(obj, property=None):
15601560
"""
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.
15621562
15631563
Parameters
15641564
----------
@@ -1579,6 +1579,10 @@ def getp(obj, property=None):
15791579
e.g.:
15801580
15811581
linewidth or lw = 2
1582+
1583+
See Also
1584+
--------
1585+
setp
15821586
"""
15831587
if property is None:
15841588
insp = ArtistInspector(obj)
@@ -1593,52 +1597,59 @@ def getp(obj, property=None):
15931597

15941598
def setp(obj, *args, file=None, **kwargs):
15951599
"""
1596-
Set a property on an artist object.
1600+
Set one or more properties on an `.Artist`, or list allowed values.
15971601
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::
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.
16021608
1603-
>>> line, = plot([1, 2, 3])
1604-
>>> setp(line, linestyle='--')
1609+
For example, two lines can be made thicker and red with a single call:
16051610
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::
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')
16081614
1609-
>>> setp(line, 'linestyle')
1610-
linestyle: {'-', '--', '-.', ':', '', (offset, on-off-seq), ...}
1615+
file : file-like or None, default: `sys.stdout`
1616+
Where `setp` writes its output, e.g. ::
1617+
1618+
with open('output.log') as file:
1619+
setp(line, file=file)
16111620
1612-
If you want to see all the properties that can be set, and their
1613-
possible values, you can do::
1621+
args, kwargs
1622+
The set properties. The following combinations are supported:
16141623
1615-
>>> setp(line)
1616-
... long output listing omitted
1624+
- Set the linestyle of a line to be dashed:
16171625
1618-
By default `setp` prints to `sys.stdout`, but this can be modified using
1619-
the *file* keyword-only argument::
1626+
>>> line, = plot([1, 2, 3])
1627+
>>> setp(line, linestyle='--')
1628+
1629+
- Set multiple properties at once:
1630+
1631+
>>> setp(line, linewidth=2, color='r')
1632+
1633+
- List allowed values for a line's linestyle:
1634+
1635+
>>> setp(line, 'linestyle')
1636+
linestyle: {'-', '--', '-.', ':', '', (offset, on-off-seq), ...}
16201637
1621-
>>> with fopen('output.log') as f:
1622-
>>> setp(line, file=f)
1638+
- List all properties that can be set, and their allowed values:
16231639
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::
1640+
>>> setp(line)
1641+
agg_filter: a filter function, ...
1642+
[long output listing omitted]
16301643
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')
1644+
`setp` also supports MATLAB style string/value pairs. For example, the
1645+
following are equivalent:
16361646
1637-
:func:`setp` works with the MATLAB style string/value pairs or
1638-
with python kwargs. For example, the following are equivalent::
1647+
>>> setp(lines, 'linewidth', 2, 'color', 'r') # MATLAB style
1648+
>>> setp(lines, linewidth=2, color='r') # Python style
16391649
1640-
>>> setp(lines, 'linewidth', 2, 'color', 'r') # MATLAB style
1641-
>>> setp(lines, linewidth=2, color='r') # python style
1650+
See Also
1651+
--------
1652+
getp
16421653
"""
16431654

16441655
if isinstance(obj, Artist):

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.