@@ -1518,33 +1518,32 @@ def _map_face2color(face, colormap, vmin, vmax):
1518
1518
"and vmax. The vmin value cannot be "
1519
1519
"bigger than or equal to the value "
1520
1520
"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 )
1529
1527
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 )))
1533
1532
1534
1533
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 )
1538
1537
1539
1538
else :
1540
- t_color = FigureFactory ._find_intermediate_color (
1539
+ face_color = FigureFactory ._find_intermediate_color (
1541
1540
colormap [low_color_index ],
1542
1541
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 )
1546
1545
1547
- return color
1546
+ return face_color
1548
1547
1549
1548
@staticmethod
1550
1549
def _trisurf (x , y , z , simplices , colormap = None , color_func = None ,
0 commit comments