Passing a variable number of arguments to a wrapped function.
John Hunter
jdhunter at ace.bsd.uchicago.edu
Fri Aug 5 13:39:21 EDT 2005
>>>>> "stephen" == stephen <stephen at theboulets.net> writes:
stephen> Is there a better way of doing this so that I don't have
stephen> to go through every permutation of possible arguments
stephen> (the example here from the matplotlib 'plot' function):
You can make linecolor=None and linewidth=None, and then use
matplotlib's rc defaults
from matplotlib import rcParams
def makeplot(self, xvalues, yvalues, linecolor=None, linewidth=None):
if linecolor is None: linecolor = rcParams['lines.color']
if linewidth is None: linewidth = rcParams['lines.linewidth']
plot(xvalues, yvalues, color=linecolor, linewidth=linewidth)
Then you can customize the defaults in the rc file
(http://matplotlib.sf.net/matplotlibrc) any way you want.
Alternatively, you can also set the defaults in your script
from matplotlib import rc
rc('lines', linewidth=1.0, color='red')
JDH
More information about the Python-list
mailing list