Reputation: 6284
I have the following code that is mostly copy/pasted form the plotly website. I get an attribute error code with the line "fig.add_hline(y=0.9)". Why do I get this error?
import plotly as py
import plotly.express as px
print("plotly version: ", py.__version__)
df = px.data.iris()
fig = px.scatter(df, x="petal_length", y="petal_width")
fig.add_hline(y=0.9)
fig.add_vrect(x0=0.9, x1=2)
fig.show()
Output:
plotly version: 4.8.2
AttributeError: 'Figure' object has no attribute 'add_hline'
Thank you.
Upvotes: 2
Views: 2793
Reputation: 61154
Horizontal and vertical lines and rectangles are introduced in plotly 4.12.
You're on 4.8.2
so you'll have to run an update.
Upvotes: 2