@@ -1518,33 +1518,32 @@ def _map_face2color(face, colormap, vmin, vmax):
15181518                                         "and vmax. The vmin value cannot be " 
15191519                                         "bigger than or equal to the value " 
15201520                                         "of vmax." )
1521-         # find the normalized distance t of a triangle face between vmin and 
1522-         #vmax where the distance is normalized between 0 and 1 
1523-         t  =  (face  -  vmin ) /  float ((vmax  -  vmin ))
1524- 
1525-         if  len (colormap ) <=  1 :
1526-             t_color  =  colormap [0 ]
1527-             color  =  FigureFactory ._convert_to_RGB_255 (t_color )
1528-             color  =  FigureFactory ._label_rgb (color )
1521+ 
1522+         if  len (colormap ) ==  1 :
1523+             # color each triangle face with the same color in colormap 
1524+             face_color  =  colormap [0 ]
1525+             face_color  =  FigureFactory ._convert_to_RGB_255 (face_color )
1526+             face_color  =  FigureFactory ._label_rgb (face_color )
15291527        else :
1530-             # account for colormaps with more than one color 
1531-             incr  =  1. / (len (colormap ) -  1 )
1532-             low_color_index  =  int (t / incr )
1528+             # find the normalized distance t of a triangle face between vmin 
1529+             # and vmax where the distance is normalized between 0 and 1 
1530+             t  =  (face  -  vmin ) /  float ((vmax  -  vmin ))
1531+             low_color_index  =  int (t  /  (1. / (len (colormap ) -  1 )))
15331532
15341533            if  t  ==  1 :
1535-                 t_color  =  colormap [low_color_index ]
1536-                 color  =  FigureFactory ._convert_to_RGB_255 (t_color )
1537-                 color  =  FigureFactory ._label_rgb (color )
1534+                 face_color  =  colormap [low_color_index ]
1535+                 face_color  =  FigureFactory ._convert_to_RGB_255 (face_color )
1536+                 face_color  =  FigureFactory ._label_rgb (face_color )
15381537
15391538            else :
1540-                 t_color  =  FigureFactory ._find_intermediate_color (
1539+                 face_color  =  FigureFactory ._find_intermediate_color (
15411540                    colormap [low_color_index ],
15421541                    colormap [low_color_index  +  1 ],
1543-                     ( t   -   low_color_index   *   incr )  /   incr )
1544-                 color  =  FigureFactory ._convert_to_RGB_255 (t_color )
1545-                 color  =  FigureFactory ._label_rgb (color )
1542+                     t   *  ( len ( colormap )  -   1 )  -   low_color_index )
1543+                 face_color  =  FigureFactory ._convert_to_RGB_255 (face_color )
1544+                 face_color  =  FigureFactory ._label_rgb (face_color )
15461545
1547-         return  color 
1546+         return  face_color 
15481547
15491548    @staticmethod  
15501549    def  _trisurf (x , y , z , simplices , colormap = None , color_func = None ,
0 commit comments