Closed
Description
It was already "reported" at https://stackoverflow.com/q/67373687/5776000 that add_hline()
is not working with a secondary axis. Here a bit more simplified MWE than given in the above link:
import plotly.express as px
import plotly.graph_objects as go
import numpy as np
df = px.data.iris()
fig = px.scatter(df, x="petal_length", y="petal_width")
fig.add_traces(go.Scatter(y=np.arange(1, 7), mode="lines+markers", yaxis='y2'))
fig.add_hline(y=2, line_dash='dash', line_color='Red', yref='y2')
fig.update_layout(
yaxis2=dict(
title="yaxis2 title",
overlaying="y",
side="right",
)
)
fig.show()
As can be seen in the output, the hline
is "linked" to the primary axis instead of to the secondary axis.
Metadata
Metadata
Assignees
Labels
No labels