Skip to content

Histogram should not prepend any text to axis and hover labels (e.g. "sum of ...") #3694

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
brylie opened this issue Apr 27, 2022 · 3 comments
Labels
feature something new P3 backlog

Comments

@brylie
Copy link

brylie commented Apr 27, 2022

Split from #2876

We need to localize all texts in our project. So, we can't rely on auto-generated, English labels such as "sum of" or "probability."

Issue

The following code produces the correct chart. However, the auto-generated phrase "sum of" appears in the axis label and hover text.

px.histogram(
    chart_data,
    x="role_name",
    y="total_minutes",
    color="work_type",
    labels={
        # notice here the use of _("") localization function
        "role_name": _("Caregiver role"),
        "total_minutes": _("total minutes"),
        "work_type": _("Type of work"),
    },
)

image

image

Expected outcome

The desired output would be that the y-axis label and hover text would be "total minutes" rather than "sum of total minutes," the latter of which we cannot localize. Specifically, when labels are defined for chart dimensions, the aggregation type ("sum of" in this case) should not be prepended to the text, since the content and data language may not be English.

brylie added a commit to GeriLife/caregiving that referenced this issue Apr 27, 2022
brylie added a commit to GeriLife/caregiving that referenced this issue Apr 27, 2022
brylie added a commit to GeriLife/caregiving that referenced this issue Apr 27, 2022
brylie added a commit to GeriLife/caregiving that referenced this issue Apr 27, 2022
brylie added a commit to GeriLife/caregiving that referenced this issue Apr 27, 2022
@nicolaskruchten
Copy link
Contributor

This requests makes sense but can't make it the default behaviour as 1) it would be a backwards-incompatible change and 2) when doing exploratory analysis it's extremely important that the Y axis correctly displays the operation being done on the data.

I would be open to a pull request which added a flag to all PX functions that accept histnorm to suppress this output.

@Mingmei2020
Copy link

Hi, Brylie, I have encountered the same problem, have you found a way to remove the "sum of" from the y-axis label?

@brylie
Copy link
Author

brylie commented Jun 13, 2022

I was able to remove the text using the example from @nicolaskruchten

#2876 (comment)

@gvwilson gvwilson self-assigned this Jul 4, 2024
@gvwilson gvwilson removed their assignment Aug 2, 2024
@gvwilson gvwilson added P3 backlog feature something new labels Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature something new P3 backlog
Projects
None yet
Development

No branches or pull requests

4 participants