Skip to content

Commit 35cbe11

Browse files
Merge pull request #3478 from janosh/master
Fix to_rgb_color_list when passing rgba colors
2 parents 6a023af + 9a9a67c commit 35cbe11

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

Diff for: CHANGELOG.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).
44

55
## UNRELEASED
66

7+
### Fixed
8+
- Fixed ValueError when `ff.create_annotated_heatmap` passes `rgba()` colors into `to_rgb_color_list` [#3478](https://github.com/plotly/plotly.py/issues/3478)
9+
710
### Added
811

912
- `text_auto` argument to `px.bar`, `px.histogram`, `px.density_heatmap`, `px.imshow` [#3518](https://github.com/plotly/plotly.py/issues/3518)
@@ -15,7 +18,6 @@ This project adheres to [Semantic Versioning](http://semver.org/).
1518
- texttemplate for histogram-like traces
1619
- text for heatmap-like traces
1720

18-
1921
## [5.4.0] - 2021-11-15
2022

2123
### Fixed

Diff for: packages/python/plotly/plotly/figure_factory/_annotated_heatmap.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import absolute_import, division
22

3-
from plotly import exceptions, optional_imports
43
import plotly.colors as clrs
4+
from plotly import exceptions, optional_imports
55
from plotly.figure_factory import utils
66
from plotly.graph_objs import graph_objs
77
from plotly.validators.heatmap import ColorscaleValidator
@@ -150,9 +150,10 @@ def create_annotated_heatmap(
150150

151151

152152
def to_rgb_color_list(color_str, default):
153-
if "rgb" in color_str:
154-
return [int(v) for v in color_str.strip("rgb()").split(",")]
155-
elif "#" in color_str:
153+
color_str = color_str.strip()
154+
if color_str.startswith("rgb"):
155+
return [int(v) for v in color_str.strip("rgba()").split(",")]
156+
elif color_str.startswith("#"):
156157
return clrs.hex_to_rgb(color_str)
157158
else:
158159
return default

0 commit comments

Comments
 (0)