🚀 Gen 5 of the leading AI app deployment platform launches October 6. Click for the livestream.

Customizing text on x unified hovering

I’m using “x unified” hovermode on a plot where the x-axis variable is a date. I’d like to be able to customize the date format that appears when you hover over the plot (e.g. display the day of the week). I can do this pretty easily using hovertemplate for the text that appears next to each trace (there are multiple lines on the plot) but I can’t figure out how to customize the date format for the x unified date that appears at the top of the pop-up. Any suggestions?

1 Like

Perhaps in your case it would suffice to format the xvalues before you start plotting anything.

I have a similar problem, only that I would like to change the title of the hoverlabel completely (i.e. use ticklabels instead of x = tickvalues, which are used as a default)

There seems to be no attribute with which you can set/modify the title directly in the figure object.
Can anyone help?

You can use layout.xaxis.hoverformat :slight_smile:

Hi Nicolas,
I currently have a similar issue as discussed above. I would like to have a plot in hovermode “x unified” with a customized title of the hover label. The title of the hover label is by default set to the x-axis value. On the x-axis, I want to show only ever second x-tick and customize the x-ticklabels. I use tickvals and ticktext to achieve that. Here is the problem: When I do that, the title of the hover label is set to the value in ticktext if the corresponding tickval exists or to the original x-axis value if the corresponding tickval does not exist. I would like the hover label title to always follow the ticktext format. How can this be achieved?

1 Like

I currently have a similar issue as discussed above. I would like to have a plot in hovermode “x unified” with a customized title of the hover label. The title of the hover label is by default set to the x-axis value. On the x-axis, I want to show only ever second x-tick and customize the x-ticklabels. I use tickvals and ticktext to achieve that. Here is the problem: When I do that, the title of the hover label is set to the value in ticktext if the corresponding tickval exists or to the original x-axis value if the corresponding tickval does not exist. I would like the hover label title to always follow the ticktext format. How can this be achieved?

I"m not really following the desire here… can you provide a concrete example with a screenshot or something please?

Hi I have a similar need, i.e. to customize the title of the hover box in the “x unified” hover mode.
I am visualizinf a dataframe with some numerical data and some categorical data.
Each trace is a line relevant to a numerical column
x is a timeline in seconds.
when hovering over second x I’d like to see in the title of the hover box the number of the second plus the value of
some categorical columns relevant to the same dataframe row as second x.

I’m not certain I have the same requirements as the other posters, but in this screenshot:

I would like to have the tooltip:

  • Not include the x-axis label (“Dec”);
  • Not include the coloured blocks corresponding to the bar colours;
  • Not include the text assigned to the bars (“R”, “A”, “G”) on a separate line beneath the values;
  • And I would like to be able to modify the order of the bars in the tooltip, in this case such that the “Missing data” value is last.

All of this seems, in principle, as if it should be achievable using a hovertemplate but in practice it doesn’t seem possible. Various properties appear, from my experiments, to affect the formatting of specific parts; but not of the whole.

I haven’t found anything in the documentation suggesting that the hovertemplate of a stacked x-unified bar chart can’t be customised in those ways, and something must be assembling it in that format, but what that may be doesn’t seem to be specified anywhere.

So the desire, at least in my case, is to have configuration options available and documented that allow the hover box of a stacked x-unified bar chart to be customised, if only in terms of specifying which of the various components should be included or excluded.

Did anyoune understand how to customize the title of the hover box in the “x unified” hover mode?