plotly / plotly/plotly.py

Error bars in px.scatter should inherit color and opacity from markers by default

Open
#4,353 1 comment 0 reactions 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

Error bars do correctly show with the same color (not opacity) as markers when using categorical data to set the color parameter:

import plotly.express as px
df = px.data.iris()
df["e_plus"] = df["sepal_width"]/100
df["e_minus"] = df["sepal_width"]/40
fig = px.scatter(df, x="sepal_width", y="sepal_length", color="species",
                 error_y="e_plus", error_y_minus="e_minus")

fig.show()
image

However, setting the opacity parameter only changes the opacity of the markers:

fig = px.scatter(df, x="sepal_width", y="sepal_length", color="species",
                 error_y="e_plus", error_y_minus="e_minus", opacity=0.6)

fig.show()
image

And using numerical data to set the color parameter, the error bars will not have the same color as the markers, but instead renders in black:

fig = px.scatter(df, x="sepal_width", y="sepal_length", color="petal_width",
                 error_y="e_plus", error_y_minus="e_minus")

fig.show()
image

Fixing this would be super helpful, since the only current solution seems to be to manually add or update the trace for every single data point to set rgba-values for the error bars. My scatter plot had a few thousand data points, making that a very time consuming for-loop.

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 with the provided px.scatter reproductions using categorical and numerical color values, with and without opacity. Inspect the generated error-bar and marker settings to identify where their color and opacity diverge. Done means error bars inherit the marker color and opacity by default in all shown cases, with coverage for the reproductions.

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
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.