From a41465370a1f2d4bd90fa50b474196dd669a3f96 Mon Sep 17 00:00:00 2001 From: Janosh Riebesell Date: Thu, 18 Nov 2021 09:08:08 +0000 Subject: [PATCH 1/2] fix to_rgb_color_list when passing rgba colors (closes #3477) --- .../plotly/plotly/figure_factory/_annotated_heatmap.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/python/plotly/plotly/figure_factory/_annotated_heatmap.py b/packages/python/plotly/plotly/figure_factory/_annotated_heatmap.py index e6253c43afe..1402956e3e6 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 @@ -147,9 +147,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 From 773b373d1a1bc3fa69073f08a7d0dd77c6055b3d Mon Sep 17 00:00:00 2001 From: Janosh Riebesell Date: Wed, 24 Nov 2021 14:33:32 +0000 Subject: [PATCH 2/2] add changelog entry --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6129ff037b6..da2bb52ab47 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +### 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) + ## [5.4.0] - 2021-11-15 ### Fixed