GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Plot types
  • User guide
  • Tutorials
  • Examples
  • Reference
  • Contribute
  • Releases
  • Gitter
  • Discourse
  • GitHub
  • matplotlib
  • matplotlib.animation
  • matplotlib.animation.Animation
  • matplotlib.animation.FuncAnimation

This view

  • Original page
  • New address

GeezerVison is showing matplotlib.org — matplotlib.pyplot.setp — Matplotlib 3.11.2 documentation

matplotlib.pyplot.setp#

matplotlib.pyplot.setp(obj, *args, **kwargs)[source]#

Set one or more properties on an Artist, or list allowed values.

Parameters:
objArtist or list of Artist

The artist(s) whose properties are being set or queried. When setting properties, all artists are affected; when querying the allowed values, only the first instance in the sequence is queried.

For example, two lines can be made thicker and red with a single call:

>>> x = arange(0, 1, 0.01)
>>> lines = plot(x, sin(2*pi*x), x, sin(4*pi*x))
>>> setp(lines, linewidth=2, color='r')
filefile-like, default: sys.stdout

Where setp writes its output when asked to list allowed values.

>>> with open('output.log') as file:
...     setp(line, file=file)

The default, None, means sys.stdout.

*args, **kwargs

The properties to set. The following combinations are supported:

  • Set the linestyle of a line to be dashed:

    >>> line, = plot([1, 2, 3])
    >>> setp(line, linestyle='--')
    
  • Set multiple properties at once:

    >>> setp(line, linewidth=2, color='r')
    
  • List allowed values for a line's linestyle:

    >>> setp(line, 'linestyle')
    linestyle: {'-', '--', '-.', ':', '', (offset, on-off-seq), ...}
    
  • List all properties that can be set, and their allowed values:

    >>> setp(line)
    agg_filter: a filter function, ...
    [long output listing omitted]
    

setp also supports MATLAB style string/value pairs. For example, the following are equivalent:

>>> setp(lines, 'linewidth', 2, 'color', 'r')  # MATLAB style
>>> setp(lines, linewidth=2, color='r')        # Python style

See also

getp

Notes

Note

This is equivalent to matplotlib.artist.setp.

Examples using matplotlib.pyplot.setp#

Boxplots

Boxplots

Patheffect Demo

Patheffect Demo

Set and get properties

Set and get properties

Topographic hillshading

Topographic hillshading

The Lifecycle of a Plot

The Lifecycle of a Plot
On this page
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.