Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add_hline() not working with secondary axis #3755

Closed
Mo-Gul opened this issue Jun 2, 2022 · 2 comments
Closed

add_hline() not working with secondary axis #3755

Mo-Gul opened this issue Jun 2, 2022 · 2 comments

Comments

@Mo-Gul
Copy link

Mo-Gul commented Jun 2, 2022

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()

image showing the result of above code

As can be seen in the output, the hline is "linked" to the primary axis instead of to the secondary axis.

@lmmentel
Copy link

I can confirm, experiencing the same issue where add_hline ignores yref argument and defaults to primary yaxis

zfoltz added a commit to zfoltz/plotly.py that referenced this issue Apr 21, 2023
zfoltz added a commit to zfoltz/plotly.py that referenced this issue Apr 21, 2023
alexcjohnson added a commit that referenced this issue Jun 3, 2023
…_yref_bug

Issue #3755 Bug Fix for: Shapes and Annotations With yref Parameter Not Drawing on Correct Axis
@zfoltz
Copy link
Contributor

zfoltz commented Aug 31, 2023

Whoops, forgot to circle back to this issue. This has been fixed and can be closed! @Mo-Gul see PR #4177

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants