question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Common hover label for hovermode = 'closest'

See original GitHub issue

For scatter plots with hovermode == closest, the current default behavior for hover labels is to only show one hover label near the data point, representing the X and Y data information. However, me (and maybe others?) think that this behavior doesn’t look good. The labels is too cluttered and shows too much information, which makes it difficult to interpret.

At the moment, the hover label is rather complex and visually, the labels are much easier to understand if they’d work similarly to hovermode == x, meaning that the X value is shown as hover label near the X axis and the Y value is shown in the hover label near the data point.

I already implemented this locally, but I wanted to bring this back upstream, as I think it is generally desired. I found multiple threads around the internet where people wanted to have this behavior.

As-is

grafik

To-be

grafik

(Screenshots taken from this interactive version: https://stackoverflow.com/a/39259137/6156346)

Benefits

  • Better consistency with other plot types, most of them (like bar plots, boxplots, etc.) show a common label on the x axis.

Discussion

  • Do you think this could be a meaningful default behavior?
  • Or should we add an option for it?
  • Is there another way to achieve common x label without modifying the plotly library?

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
valentinstncommented, Oct 29, 2021

Hi @nicolaskruchten, thanks for your answer:

It seems like you prefer the x mode and you can force it by setting layout.hovermode=‘x’ but we will not be changing the default back in the foreseeable future 😃

Actually, I like the hovermode == closest. It makes much more sense than x. I just don’t like the visual representation of the hover label, as it is quiet cluttered with too much data and difficult to read. What I would prefer is having hovermode == closest with the hover label style of hovermode == x.

0reactions
Lxstrcommented, Aug 22, 2022

@nicolaskruchten would be great! My thoughts:

As you said, I believe it would make sense to have new attribute to independently control which labels are highlighted on hover.

It is possible to want to use hovermode “closest” but need to highlight a particular tick label that helps the user better grasp the position of the datapoint. Without this feature one might opt to print the x or y values into the hover template itself, however I think this detracts from the user experience by adding clutter when there is already significant hovertemplate information to digest. (my current situation)

Conversly, there is no assumed reason you would need the tick label highlighting that automatically comes with hovermode “x” or “y”. This way you could turn them off when not wanted.

Attribute use:

hoverticklabel = "y"
hoverticklabel = "x"
hoverticklabel = "x+y"
hoverticklabel = "none"
hoverticklabel="automatic"

Perhaps by having a default option as automatic/inherit we can avoid having to break any existing expected behaviour.

@valentinstn How did you go with your previous implementation? Are you able to share the code please?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Hover text and formatting in Python - Plotly
There are three hover modes available in Plotly. The default setting is layout.hovermode='closest' , wherein a single hover label appears for the point...
Read more >
Python Dash Plotly: Show default closest data on hover or ...
Setting your graph default to showing closest data in plotly dash can be done by adding hovermode to the figure, as follows:
Read more >
Hover Text and Formatting in Python-Plotly - GeeksforGeeks
The default setting is layout.hovermode='closest', wherein a single hover label appears for the point directly underneath the cursor.
Read more >
Interactions - Chart.js
By default, these options apply to both the hover and tooltip interactions. ... A common occurrence is taking an event, such as a...
Read more >
Configuring plot tools — Bokeh 2.4.3 Documentation
Basic Tooltips#. By default, the hover tool generates a “tabular” tooltip where each row contains a label and its associated value. The labels...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found