Disabling default ToolTip while using a HoverTemplate in Python

Hi,

I was wondering if there was any way to disable the default tooltip information when applying a hovertemplate.
I get that there is an easy way of doing so by using hoverinfo=..., but later on putting a hovertemplate through update_traces() cancels this effect.
Would there be a way to have the tooltip stop displaying the trace the cursor is on, or, in a violinplot, the max, upper and lower fence etc. while using a hovertemplate ?

I have seen the subject covered in JavaScript, but the trick there doesnโ€™t seem to be transposable to Python.

Thank you for your help!

Hi @B1jam1 ,

Welcome to the forum!

I donโ€™t know why you should applying the hovertemplate although you donโ€™t want to display the tooltip.

As far as I know based on the docs.
https://plotly.com/python-api-reference/generated/plotly.graph_objects.html#plotly.graph_objects.Scatter.hovertemplate

hovertemplate will override hoverinfo attribute, it means that even if you set the hoverinfo as โ€˜noneโ€™ or โ€˜skipโ€™ it will show the tooltip until you set hovertemplate attribute with empty string or None.

1 Like

Hello @farispriadi,

Thank you for your answer!
I do want to display the tooltip, but I want to control what data is displayed.
The hovertemplate allows me to add custom information on the hover, but also comes with some default information I do not want to be displayed. It might be more explicit in the following pictures:


On these two pictures, the name of the trace the information is extracted from is shown on the right-hand side of the hover. I did not explicitly specify to do so in my knowledge. Would you know how to get rid of these?

Thank you for your help!

Hello again,

I just found how to do so in the link you sent. Thank you very much!
One simply has to enter <extra></extra> at the end of the string given to the hovertemplate. As it is said in the documentation:

Anything contained in tag <extra> is displayed in the secondary box. [โ€ฆ] To hide the secondary box completely, use an empty tag <extra></extra>.

So in my first example, it can be removed with: hovertemplate = "Sample %{customdata[0]} <extra></extra>".

Thank you for your help!

1 Like