Python warning: plotly.graph_objs.Line is deprecated
Question:
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.
Answers:
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:UsersNIPAppDataRoamingPythonPython38site-packages”
I hope this helps.
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)',
)
)
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.
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:UsersNIPAppDataRoamingPythonPython38site-packages”
I hope this helps.
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)',
)
)