Possible to hide legend name from data tooltip?

When using a long legend name for a curve, the label on the data tooltip is cropped:

45832284-7e6b1800-bccf-11e8-8e0a-612299307e48

Several people online recommend using the text property of the data object to give names that are not cropped, and this has worked for me:

However, the legend name (set in the name property) still appears, and is cropped. Is there any possible way to have a legend, but set it so the names of the legends are not displayed on the tooltip?

1 Like

Hi @mathieuboudreau,

You can specify what info shows up in the hover tooltip using the scatter.hoverinfo property. Hereโ€™s the docstring

Determines which trace information appear on hover. If `none`
or `skip` are set, no information is displayed upon hovering.
But, if `none` is set, click and hover events are still fired.

The 'hoverinfo' property is a flaglist and may be specified
as a string containing:
  - Any combination of ['x', 'y', 'z', 'text', 'name'] joined with '+' characters
    (e.g. 'x+y')
    OR exactly one of ['all', 'none', 'skip'] (e.g. 'skip')
  - A list or array of the above

The default is all, which shows everything. Youโ€™ll want to set it to something that doesnโ€™t include name. Maybe 'x+y+text.

Hope that helps!
-Jon

1 Like

Worked perfectly - thanks a lot @jmmease!

1 Like

I still have a problem,

however this works well without hovertemplate,

If I have my customised template, then the hoverinfo is not working
this.Level ={
x: this.x,
y: this.y1,
xaxis:โ€˜xโ€™,
yaxis:โ€˜yโ€™,
hoverinfo: โ€˜x+yโ€™,
hovertemplate:โ€˜one:%{y}%
โ€™+
โ€˜two:%{y}%
โ€™+
โ€˜threel:%{y}mm
โ€™ ,
type: โ€˜scatterโ€™,
mode: โ€˜lines+markersโ€™,
name: โ€˜Actual Levelโ€™,
line:{
color:โ€™#aa1d5fโ€™,
shape:โ€˜splineโ€™,
smoothing:โ€™.4โ€™
},
marker: {
color:โ€™#ffffffโ€™,
size: 10,
line: {color: โ€˜#aa1d5fโ€™,width: 1}
}
};

In this case I still get a trailing legend name associated

If using hovertemplate you can set hoverlabel.namelength to 0 to hide the secondary bit :slight_smile:

1 Like

Alternatively, you can put whatever you like in that secondary area (including nothing) when using hovertemplate by wrapping it in <extra></extra> inside the hovertemplate text.

1 Like

Can you give a more detailed explanation? if possible an example? Thank you!

This section of the docs should help: Hover Text and Formatting | Python | Plotly