Skip to content

plotly.graph_objects.Scatter property fillgradient does not plot gradients with v5.22.0 in python #4649

Open
@JulienRim

Description

@JulienRim

Description

I am trying to use the fillgradient in a scatter plot with plotly.
I copied the documentation code for its use, but on code execution, the gradient does not appear.

Operating system & Environment

  • OS: macOS Sonoma 14.5
  • language: python 3.11.3
  • relevant libraries (working on VSCode in a jupyter notebook)
    • plotly 5.22.0
    • jupyterlab 3.6.3
    • ipywidgets 8.0.4
    • notebook 6.5.4

Code used

import plotly.graph_objects as go

fig = go.Figure(
    [
        go.Scatter(
            x=[1, 2, 3, 4],
            y=[3, 4, 8, 3],
            fill=None,
            mode="lines",
            line_color="darkblue",
        ),
        go.Scatter(
            x=[1, 2, 3, 4],
            y=[1, 6, 2, 6],
            fill="tonexty",
            mode="lines",
            line_color="darkblue",
            fillgradient=dict(
                type="horizontal",
                colorscale=[(0.0, "darkblue"), (0.5, "royalblue"), (1.0, "cyan")],
            ),
        ),
    ]
)

fig.show()

Output in picture:
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3backlogbugsomething broken

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions