def setp(h, *args, **kwargs):
insp = ArtistInspector(h)<EOL>if len(kwargs)==<NUM_LIT:0> and len(args)==<NUM_LIT:0>:<EOL><INDENT>print('<STR_LIT:\n>'.join(insp.pprint_setters()))<EOL>return<EOL><DEDENT>if len(kwargs)==<NUM_LIT:0> and len(args)==<NUM_LIT:1>:<EOL><INDENT>print(insp.pprint_setters(prop=args[<NUM_LIT:0>]))<EOL>return<EOL><DEDENT>if not cbook.iterable(h): h = [h]<EOL>else: h = cbook.flatten(h)<EOL>if len(args)%<NUM_LIT:2>:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>funcvals = []<EOL>for i in range(<NUM_LIT:0>, len(args)-<NUM_LIT:1>, <NUM_LIT:2>):<EOL><INDENT>funcvals.append((args[i], args[i+<NUM_LIT:1>]))<EOL><DEDENT>funcvals.extend(list(kwargs.items()))<EOL>ret = []<EOL>for o in h:<EOL><INDENT>for s, val in funcvals:<EOL><INDENT>s = s.lower()<EOL>funcName = "<STR_LIT>"%s<EOL>func = getattr(o,funcName)<EOL>ret.extend( [func(val)] )<EOL><DEDENT><DEDENT>return [x for x in cbook.flatten(ret)]<EOL>
matplotlib supports the use of :func:`setp` ("set property") and
:func:`getp` to set and get object properties, as well as to do
introspection on the object.  For example, to set the linestyle of a
line to be dashed, you can do::

  >>> line, = plot([1,2,3])
  >>> setp(line, linestyle='--')

If you want to know the valid types of arguments, you can provide the
name of the property you want to set without a value::

  >>> setp(line, 'linestyle')
      linestyle: [ '-' | '--' | '-.' | ':' | 'steps' | 'None' ]

If you want to see all the properties that can be set, and their
possible values, you can do::

  >>> setp(line)
      ... long output listing omitted

:func:`setp` operates on a single instance or a list of instances.
If you are in query mode introspecting the possible values, only
the first instance in the sequence is used.  When actually setting
values, all the instances will be set.  E.g., suppose you have a
list of two lines, the following will make both lines thicker and
red::

  >>> x = arange(0,1.0,0.01)
  >>> y1 = sin(2*pi*x)
  >>> y2 = sin(4*pi*x)
  >>> lines = plot(x, y1, x, y2)
  >>> setp(lines, linewidth=2, color='r')

:func:`setp` works with the matlab(TM) style string/value pairs or
with python kwargs.  For example, the following are equivalent::

  >>> setp(lines, 'linewidth', 2, 'color', r')  # matlab style

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