plotly / plotly/plotly.py

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

Open
#3,770 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug P3
Dominant language
Python
Stars
18.8k
Forks
2.8k
Avg merge
16h 26m
Merged PRs (30d)
21

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the supplied Python reproduction with plotly.graph_objects.Box and compare the three traces, focusing on the interaction between line.color and fillcolor. The fix is complete when setting a box plot line color no longer changes the default fill color, so the expected example works without specifying fillcolor.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data-visualization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.