Remove 'trace 0' next to hover

Hi, in the hover documentation it shows how to customize a tooltip with a hover template.

The thing I am trying to figure out is why the top line (purple) has ‘trace 0’ in the hover, but the red line below does not. I would like to use a template, like the purple line, but don’t want the ‘trace 0’.

Appreciate your help!!

4 Likes

Hi @ssimontacchi welcome to the forum!

The <extra></extra> part of the example removes the trace name, since these tags are used to control what’s used in the second box, as explained in docstrings for hovertemplate, see for example https://plot.ly/python/reference/#scatter-hovertemplate.

9 Likes

Better yet, just set the name=“” on your trace like so:

	myFig.add_trace(
		go.Candlestick(
			x=myInputData['BarTimestamp'],
			open=myInputData['Open'],
			high=myInputData['High'],
			low=myInputData['Low'],
			close=myInputData['Close'],
			name=""), # Stops 'trace0' from showing up on popup annotation
			row=1, col=1
		)

Then you get the popup annotation for your data, without the annoying ‘trace:0’ garbage.

Really wish there were more simple solutions like this posted here. I didn’t want to customize a template or spend an hour on figuring out formatting syntax.

Hope it helps someone, it was an easy fix for what I wanted.