plotly / plotly/plotly.py

add ability to hide missing data from hover tooltip

Open
#3,515 13 comments 8 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

I have a dataframe column with some missing values which I want to include in hover_data. Is it possible to show the column in the hover tooltip only if there's value for the currently hovered point? The current default behavior is to show col_name=%{customdata[0]} for missing values. I think it would be better to show nothing at all.

Screen Shot 2021-12-14 at 13 16 13

import plotly.express as px

df = px.data.gapminder().query("continent=='Oceania'")

df["pop"] = None

fig = px.line(
    df,
    x="year",
    y="lifeExp",
    color="country",
    hover_data=["pop"],
    title="layout.hovermode='closest' (the default)",
)
fig.update_traces(mode="markers+lines")

fig.show()

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 by reproducing the provided Python example with plotly.express.line and hover_data, then trace how missing values become hover tooltip text. Done means points with missing values no longer display the hover column, while populated values remain visible; add or update coverage for this behavior if the relevant test area is found.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.