Skip to content

Commit

Permalink
Merge pull request #3478 from janosh/master
Browse files Browse the repository at this point in the history
Fix to_rgb_color_list when passing rgba colors
  • Loading branch information
nicolaskruchten authored Dec 20, 2021
2 parents 6a023af + 9a9a67c commit 35cbe11
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 35cbe11

Please sign in to comment.