plotly / plotly/plotly.py

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

Open
#3,694 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature P3
Dominant language
Python
Stars
18.8k
Forks
2.8k
Avg merge
16h 26m
Merged PRs (30d)
21

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the px.histogram example and its labels argument, then trace how histogram axis and hover labels are generated. Verify that localized dimension labels such as “total minutes” are shown without an automatically prepended aggregation phrase in both places.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data-visualization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.