Hi Everyone, I am trying the matplotlib. I have to say this is a powerful package for scientific 2-D plotting. However, I encountered some problems when try to generate several colormaps.
for example: a=cm.get_cmap('gist_rainbow',256)(range(256)) will give a error: Traceback (most recent call last): File "<pyshell#82>", line 1, in <module> a=cm.get_cmap('gist_rainbow',256)(range(256)) File "...\site-packages\matplotlib\colors.py", line 498, in __call__ if not self._isinit: self._init() File "...\site-packages\matplotlib\colors.py", line 649, in _init self._segmentdata['red'], self._gamma) TypeError: tuple indices must be integers, not str but other colormaps can actually work: a=cm.get_cmap('gist_stern',256)(range(256)) >>> a array([[ 0. , 0. , 0. , 1. ], [ 0.0716923 , 0.00392157, 0.00784314, 1. ], [ 0.14338459, 0.00784314, 0.01568627, 1. ], ..., [ 0.99215686, 0.99215686, 0.97040326, 1. ], [ 0.99607843, 0.99607843, 0.98520163, 1. ], [ 1. , 1. , 1. , 1. ]]) I tried all possible colormaps and found out: gist_rainbow, terrain, bwr, brg, and seismic will generate the same error, all other colormaps are OK. I wonder is this a bug or expected behavior? ############################### ##matplotlib verison : '1.0.svn' >>> maps=[m for m in cm.datad if not m.endswith("_r")] >>> for i in maps: try: a=cm.get_cmap(i,256)(range(256)) except: (type, value, traceback) = sys.exc_info() print "Problems to create %s" % (i,) print "The error was --> %s: %s" % (type, value) Problems to create gist_rainbow The error was --> <type 'exceptions.TypeError'>: tuple indices must be integers, not str Problems to create terrain The error was --> <type 'exceptions.TypeError'>: tuple indices must be integers, not str Problems to create bwr The error was --> <type 'exceptions.TypeError'>: tuple indices must be integers, not str Problems to create brg The error was --> <type 'exceptions.TypeError'>: tuple indices must be integers, not str Problems to create seismic The error was --> <type 'exceptions.TypeError'>: tuple indices must be integers, not str ################################################################## ------------------------------------------------------------------------------ Download new Adobe(R) Flash(R) Builder(TM) 4 The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly Flex(R) Builder(TM)) enable the development of rich applications that run across multiple browsers and platforms. Download your free trials today! http://p.sf.net/sfu/adobe-dev2dev _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users