plotly.py icon indicating copy to clipboard operation
plotly.py copied to clipboard

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

Open JulienRim opened this issue 1 year ago • 3 comments

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

JulienRim avatar Jun 28 '24 17:06 JulienRim

hi @JulienRim I'm getting this plot with Plotly 5.22.0. I'm using PyCharm and Firefox

image

Coding-with-Adam avatar Jul 08 '24 17:07 Coding-with-Adam

@Coding-with-Adam Thanks for looking into this.

I took another look into this issue on my end, and I believe it to be related to using jupyter notebooks in VSCode. I cannot confirm if this is unique to MacOS or not.

I tried running this in a jupyter environment in a new terminal window: conda activate <env_with_plotly_5.22.0> jupyter notebook or jupyter lab

Running the same code as above yields the plot with fillgradient, as expected. When I went back to VSCode with the same jupyter notebook, it yielded the plot that I posted when I initially opened the ticket.

JulienRim avatar Jul 12 '24 21:07 JulienRim

Can confirm the same behavior as OP, Plotly V5.24.0 & Mac OS 14.6.1, gradient does not appear to work within VS Code Jupyter.

deeleeramone avatar Sep 13 '24 22:09 deeleeramone