9

Although everything works fine, I would like to know whether there is a way to fix what is provoking this warning:

plotly.graph_objs.Line is deprecated. Please replace it with one of the following more specific types

  • plotly.graph_objs.scatter.Line
  • plotly.graph_objs.layout.shape.Line
  • etc.
2
  • Ok. I learned I can edit the packages by myself (newbie python user here). I used the suggestion provided by the warning message. Commented Jan 28, 2020 at 21:47
  • 2
    Would you care to share exactly what you did? Maybe write it up as a full answer? Commented Jan 29, 2020 at 8:36

2 Answers 2

10

For me, replacing go.Line with go.Scatter and appending mode='lines' did the trick. Didn't have to change anything else, and the warning is gone.

Example:

fig.add_trace(
  go.Scatter(
    x=x, 
    y=y_upper_limit, 
    name='Upper Bound', 
    marker=dict(
      color="Red"
    ),
    mode='lines',
    fill='tonexty',
    fillcolor='rgba(167, 167, 167, 0.12)',
  )
)
Sign up to request clarification or add additional context in comments.

Comments

2

Fixing the warning regarding deprecated functions may variate, depending on the packages at use. In my particular case, I was using the "Line" function from "plotly" package. This function was being called from another package. In the latter package there was a .py file (I used "IDLE (Python 3.8 64-bit)" to edit it) that had the following code line:

from plotly.graph_objs import Line

Then, I first tried replacing that line with the suggestions provided by the warning. After a couple of tries, I ended up using the code line:

from plotly.graph_objs.scatter.marker import Line

My final script works fine like in the beginning, but this time with no warnings at all.

Note: In my case, the packages were installed in "C:\Users\NIP\AppData\Roaming\Python\Python38\site-packages"

I hope this helps.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.