plotly / plotly/plotly.py

Scattergl and px.line fill and continuous error bands don't appear

Open
#3,194 5 comments 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

Summary

Using the fill and fillcolor parameters on scattergl traces (to produce continuous error bands, for example) does not work.

Issue

The issue is specific to scattergl traces: the same parameters work fine with scatter traces. To avoid the problem with plotly.express px.line() calls requires using render_mode="svg" to avoid the use of scattergl traces.

Using graph_objects has the some problem: one must use go.Scatter() and not go.Scattergl() to get error bands.

The reference for scattergl traces (https://plotly.com/python/reference/scattergl/#scattergl-fill) indicates that the behaviour should be the same as for scatter.

Specs

Python Version: 3.8.6
Plotly Version: 4.14.3
Kaleido Version: 0.2.1

  • For image exports to be pasted here (they all looked the same as rendered in the browser)

Browsers: Firefox 88.0, Safari 12.1.1

Example

import numpy as np
import pandas as pd
import plotly.express as px

# dummy data
x = np.linspace(0, 10000, num=10_000)

df = pd.DataFrame({'x': x, 'y': x**2})
df['y_err_plus'] = df['y'] * 1.1
df['y_err_minus'] = df['y'] * 0.95
# use webgl and no fill

fig = (
px
 .line(
    df, x='x', y=['y', 'y_err_minus','y_err_plus'], 
    render_mode='webgl')
 .update_traces(
     fill='tonexty', fillcolor='red',
     selector={'name':'y_err_plus'}
 )
)
fig

fill_test

# use svg to get fill

fig = (
px
 .line(
    df, x='x', y=['y', 'y_err_minus','y_err_plus'], 
    render_mode='svg')
 .update_traces(
     fill='tonexty', fillcolor='red',
     selector={'name':'y_err_plus'}
 )
)
fig

fill_working

Sanity Check: fill to zero works?

Yes.

fig = (
px
.line(
    df, x='x', y='y', 
    render_mode='webgl')
.update_traces(fill='tozeroy')
)

fig

fill_zero

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

Reproduce the issue with px.line(render_mode="webgl") or go.Scattergl() using fill="tonexty" and fillcolor, then compare it with the working scatter and render_mode="svg" cases. Trace the scattergl rendering path and existing fill handling; done means continuous error bands render in webgl while the existing tozeroy behavior remains correct.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data-visualization
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.