Common hover label for hovermode = 'closest'
See original GitHub issueFor 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
To-be
(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:
- Created 2 years ago
- Comments:10 (5 by maintainers)
Top GitHub Comments
Hi @nicolaskruchten, thanks for your answer:
Actually, I like the
hovermode
==closest
. It makes much more sense thanx
. 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 havinghovermode
==closest
with the hover label style ofhovermode
==x
.@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:
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?