diff --git a/CHANGELOG.md b/CHANGELOG.md index ca7ae10c09f..68ba931d02f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## UNRELEASED +### Fixed + - Fixed ValueError when `ff.create_annotated_heatmap` passes `rgba()` colors into `to_rgb_color_list` [#3478](https://github.com/plotly/plotly.py/issues/3478) + ### Added - `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/). - texttemplate for histogram-like traces - text for heatmap-like traces - ## [5.4.0] - 2021-11-15 ### Fixed diff --git a/packages/python/plotly/plotly/figure_factory/_annotated_heatmap.py b/packages/python/plotly/plotly/figure_factory/_annotated_heatmap.py index c251234efc2..58773082457 100644 --- a/packages/python/plotly/plotly/figure_factory/_annotated_heatmap.py +++ b/packages/python/plotly/plotly/figure_factory/_annotated_heatmap.py @@ -1,7 +1,7 @@ from __future__ import absolute_import, division -from plotly import exceptions, optional_imports import plotly.colors as clrs +from plotly import exceptions, optional_imports from plotly.figure_factory import utils from plotly.graph_objs import graph_objs from plotly.validators.heatmap import ColorscaleValidator @@ -150,9 +150,10 @@ def create_annotated_heatmap( def to_rgb_color_list(color_str, default): - if "rgb" in color_str: - return [int(v) for v in color_str.strip("rgb()").split(",")] - elif "#" in color_str: + color_str = color_str.strip() + if color_str.startswith("rgb"): + return [int(v) for v in color_str.strip("rgba()").split(",")] + elif color_str.startswith("#"): return clrs.hex_to_rgb(color_str) else: return default