-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Fix boxplot conversion by mapping 'none' colors to transparent rgba #5700
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like you could run into the same issue with |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -336,7 +336,7 @@ def draw_bar(self, coll): | |
| yaxis="y{0}".format(self.axis_ct), | ||
| opacity=trace[0]["alpha"], # TODO: get all alphas if array? | ||
| marker=go.bar.Marker( | ||
| color=trace[0]["facecolor"], # TODO: get all | ||
| color=_export_color(trace[0]["facecolor"]), # TODO: get all | ||
| line=dict(width=trace[0]["edgewidth"]), | ||
| ), | ||
| ) # TODO ditto | ||
|
|
@@ -398,9 +398,13 @@ def draw_marked_line(self, **props): | |
| self.msg += "... with just markers\n" | ||
| mode = "markers" | ||
| if props["linestyle"]: | ||
| color = mpltools.merge_color_and_opacity( | ||
| props["linestyle"]["color"], props["linestyle"]["alpha"] | ||
| ) | ||
| if props["linestyle"]["color"] == "none": | ||
| # a fully transparent line; plotly rejects "none" as a color | ||
| color = "rgba(0,0,0,0)" | ||
| else: | ||
| color = mpltools.merge_color_and_opacity( | ||
| props["linestyle"]["color"], props["linestyle"]["alpha"] | ||
| ) | ||
|
Comment on lines
+405
to
+407
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will still throw if the line color has an alpha value, which can happen with |
||
|
|
||
| if props["coordinates"] == "data": | ||
| line = go.scatter.Line( | ||
|
|
@@ -420,22 +424,22 @@ def draw_marked_line(self, **props): | |
| if props["coordinates"] == "data": | ||
| marker = go.scatter.Marker( | ||
| opacity=props["markerstyle"]["alpha"], | ||
| color=props["markerstyle"]["facecolor"], | ||
| color=_export_color(props["markerstyle"]["facecolor"]), | ||
| symbol=mpltools.convert_symbol(props["markerstyle"]["marker"]), | ||
| size=props["markerstyle"]["markersize"], | ||
| line=dict( | ||
| color=props["markerstyle"]["edgecolor"], | ||
| color=_export_color(props["markerstyle"]["edgecolor"]), | ||
| width=props["markerstyle"]["edgewidth"], | ||
| ), | ||
| ) | ||
| else: | ||
| shape = dict( | ||
| opacity=props["markerstyle"]["alpha"], | ||
| fillcolor=props["markerstyle"]["facecolor"], | ||
| fillcolor=_export_color(props["markerstyle"]["facecolor"]), | ||
| symbol=mpltools.convert_symbol(props["markerstyle"]["marker"]), | ||
| size=props["markerstyle"]["markersize"], | ||
| line=dict( | ||
| color=props["markerstyle"]["edgecolor"], | ||
| color=_export_color(props["markerstyle"]["edgecolor"]), | ||
| width=props["markerstyle"]["edgewidth"], | ||
| ), | ||
| ) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think of combining
merge_color_and_opacityand_export_color? They seem similar enough and you could deal with converting"none"internally rather than having to add a special case. Additionally,merge_color_and_opacityonly gets called once, so we could remove that and replace it with the combined function.