Skip to content

Commit a5803b6

Browse files
Drop space in rgb and rgba color strings
1 parent b2cab76 commit a5803b6

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

plotly/matplotlylib/mpltools.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,10 @@ def merge_color_and_opacity(color, opacity):
120120

121121
rgb_tup = hex_to_rgb(color)
122122
if opacity is None:
123-
return "rgb {}".format(rgb_tup)
123+
return "rgb{}".format(rgb_tup)
124124

125125
rgba_tup = rgb_tup + (opacity,)
126-
return "rgba {}".format(rgba_tup)
126+
return "rgba{}".format(rgba_tup)
127127

128128

129129
def convert_va(mpl_va):

plotly/matplotlylib/tests/test_renderer.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,3 +233,14 @@ def test_semitransparent_axes_background_preserved():
233233
plotly_fig = tls.mpl_to_plotly(fig)
234234

235235
assert plotly_fig.layout.plot_bgcolor == "rgba(26, 51, 76, 0.4)"
236+
237+
238+
def test_line_color_is_valid_plotly_color():
239+
"""Converted line colors are valid plotly color strings: plotly rejects
240+
a space between 'rgba' and the opening parenthesis."""
241+
fig, ax = plt.subplots()
242+
ax.plot([0, 1], [0, 1], color="red")
243+
244+
plotly_fig = tls.mpl_to_plotly(fig)
245+
246+
assert plotly_fig.data[0].line.color == "rgba(255, 0, 0, 1)"

0 commit comments

Comments
 (0)