Skip to content

v5.20.0 New fillgradient not working #4549

Closed
@etiennecelery

Description

@etiennecelery

Hi all,
Been looking forward for this for a long time. New 5.20.0 version does not work for me:

import pandas as pd
import plotly.graph_objects as go
import numpy as np

x = np.linspace(0, 10, 100)
y = np.sin(x)

trace = go.Scatter(
    x=x,
    y=y,
    mode='none',
    # fillcolor="rgba(0, 255, 0, .5)",
    fillgradient=dict(
        colorscale=[
            [0.0, "rgba(0, 0, 255, 1)"],
            [0.5, "rgba(0, 255, 0, 0)"],
            [1.0, "rgba(0, 255, 0, 1)"]
        ],
        start=0,
        stop=1,
        type='horizontal',
    ), 
    fill='tonexty',
    hoveron='fills',
)
layout = go.Layout(
    plot_bgcolor='white',
    paper_bgcolor='white',
)
fig = go.Figure(trace, layout)
fig

data = {
    "data": [
        {
            "x": [1, 1, 2, 2],
            "y": [1, 2, 2, 1],
            "type": "scatter",
            "mode": "none",
            "fill": "tonext",
            "hoveron": "points+fills",
            "fillgradient": {
                "type": "horizontal",
                "colorscale": [
                    [0.0, "rgba(0, 255, 0, 1)"],
                    [0.5, "rgba(0, 255, 0, 0)"],
                    [1.0, "rgba(0, 255, 0, 1)"]
                ]
            }
        },
        {
            "x": [0, 0, 3, 3],
            "y": [0, 4, 4, 1],
            "type": "scatter",
            "mode": "none",
            "fill": "tonext",
            "hoveron": "fills+points",
                "fillgradient": {
                "type": "radial",
                "colorscale": [
                    [0.0, "rgba(255, 255, 0, 0.0)"],
                    [0.8, "rgba(255, 0, 0, 0.3)"],
                    [1.0, "rgba(255, 255, 0, 1.0)"]
                ]
            }
        }
    ],

    "layout": {
        "autosize": True,
        "title": { "text": "Scatter traces with radial color gradient fills" },
        "showlegend": True
    }
}

fig = go.Figure(data=data["data"], layout=data["layout"])

Any help will be appreciated.

This is my second ´fig´, I already checked and I am using v5.20.0
Screenshot 2024-03-14 at 18 00 57

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions