Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dda0a9a

Browse files
committed
Made facecoloring neater
1 parent c89cda1 commit dda0a9a

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

plotly/tools.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1525,17 +1525,17 @@ def _map_face2color(face, colormap, vmin, vmax):
15251525
face_color = FigureFactory._convert_to_RGB_255(face_color)
15261526
face_color = FigureFactory._label_rgb(face_color)
15271527
else:
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)))
1532-
1533-
if t == 1:
1534-
face_color = colormap[low_color_index]
1528+
if face == vmax:
1529+
# pick last color in colormap
1530+
face_color = colormap[-1]
15351531
face_color = FigureFactory._convert_to_RGB_255(face_color)
15361532
face_color = FigureFactory._label_rgb(face_color)
1537-
15381533
else:
1534+
# find the normalized distance t of a triangle face between
1535+
# vmin and vmax where the distance is between 0 and 1
1536+
t = (face - vmin) / float((vmax - vmin))
1537+
low_color_index = int(t / (1./(len(colormap) - 1)))
1538+
15391539
face_color = FigureFactory._find_intermediate_color(
15401540
colormap[low_color_index],
15411541
colormap[low_color_index + 1],

0 commit comments

Comments
 (0)