Hello, I found the following post on
> matplotlib-users. However, post reading the 'docstring', I'm
> still unable to figure it out. I don't know how to call the
> __call__ function in LinearSegmentedColormap in colors.py.
> Could someone please help me out? All I need is a one-line
> command that tells me how to give this beast a number between
> 0 and 1 and get an rgb tuple.
An instance of a class with a method __call__ can be called just like
any other function by adding parentheses after the instance
class JDH:
def __call__(self):
print 'you rang'
# create an instance of callable class JDH
jdh = JDH()
# now call the beast
jdh()
Since LinearSegmentedColormap defines call, you can do the same
>>> from matplotlib.cm import jet
>>> print jet(.5)
(0.47754585705249836, 1.0, 0.49019607843137258, 1.0)
JDH