Skip to content

Commit e5fe18a

Browse files
committed
fixed: constrain colors between 0 and 255
1 parent 133ac09 commit e5fe18a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

packages/python/plotly/_plotly_utils/colors/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -696,9 +696,9 @@ def n_colors(lowcolor, highcolor, n_colors, colortype="tuple"):
696696

697697
for index in range(n_colors):
698698
new_tuple = (
699-
lowcolor[0] + (index * incr_0),
700-
lowcolor[1] + (index * incr_1),
701-
lowcolor[2] + (index * incr_2),
699+
min(max(lowcolor[0] + (index * incr_0), 255.0), 0.0),
700+
min(max(lowcolor[1] + (index * incr_1), 255.0), 0.0),
701+
min(max(lowcolor[2] + (index * incr_2), 255.0), 0.0),
702702
)
703703
list_of_colors.append(new_tuple)
704704

0 commit comments

Comments
 (0)