Skip to content

label_textpositions don't work for shapes #5181

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

Open
Mo-Gul opened this issue May 13, 2025 · 1 comment
Open

label_textpositions don't work for shapes #5181

Mo-Gul opened this issue May 13, 2025 · 1 comment
Labels
bug something broken P3 backlog

Comments

@Mo-Gul
Copy link

Mo-Gul commented May 13, 2025

It is written that now the recommended way of adding text annotations to shapes is by adding labels. But for that the textposition is only working for ["start", "middle", "end"].

Here an MWE:

import plotly.express as px

fig = px.scatter(y=[0, 11])
# REF: <https://plotly.com/python/reference/layout/shapes/#layout-shapes-items-shape-label-textposition>
positions = [
    "top left", "top center", "top right",
    "middle left", "middle center", "middle right",
    "bottom left", "bottom center", "bottom right",
    "start", "middle", "end",
]
for i, position in enumerate(positions):
    fig.add_hline(
        y=i,
        label=dict(
            text=position,
            textposition=position,
            font_color="red",
        ),
        line_color="red",
    )
    # # same for vertical lines
    # fig.add_vline(
    #     x=i,
    #     label=dict(
    #         text=position,
    #         textposition=position,
    #         font_color="green",
    #     ),
    #     line_color="green",
    # )
    )

which gives

Image

@gvwilson gvwilson added bug something broken P3 backlog labels May 20, 2025
@gvwilson
Copy link
Contributor

thanks @Mo-Gul - I agree this would be a useful fix, but we're unlikely to be able to get to it any time soon. if you or anyone else from the community would like to submit a fix, I can try to prioritize review. thanks again - @gvwilson

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

No branches or pull requests

2 participants