plotly.py icon indicating copy to clipboard operation
plotly.py copied to clipboard

Box Plot line color changes the fill color as well, unless fill color is specified

Open tom-price-cenex opened this issue 3 years ago • 0 comments

When setting the line color for a box plot, it also makes the fill color of the box plot the same as the line color (with a different opacity I think). This is the case unless the fill color is set explicitly, but this doesn't help if for example your using a layout template for your colors. In my example below for the expected output I have to use a color picker to get the color of the default theme then put that into the fillcolor argument.

import plotly.graph_objects as go
import plotly.data
from plotly.subplots import make_subplots

data = plotly.data.iris()


fig = make_subplots(rows = 3, cols = 1, shared_xaxes=True)

fig.add_traces([
    go.Box(
            x = data["species"],
            y = data["sepal_length"],
            name = "no line color"
    ),
    go.Box(
            x = data["species"],
            y = data["sepal_length"],
            line = {"color":"black"},
            name = "line color = black"
    ),
    go.Box(
            x = data["species"],
            y = data["sepal_length"],
            fillcolor = "#a4adf8", #shouldnt need to do this
            line = {"color":"black"},
            name = "expected"
    )
], rows = [1,2,3], cols = [1,1,1])

fig

plot

tom-price-cenex avatar Jun 10 '22 11:06 tom-price-cenex