0

I'm using plotly to produce a bar chart; I've successfully created a tooltip which shows custom data associated with each bar. I heavily utilized the approach from the following stack overflow question to do so, with some minor changes in implementation because my "custom data" is not always the same each time I run this code.

How to customize hover-template on with what information to show

## for each "Experiment"
        fig.add_trace(go.Bar(name = traceName,
                            x=local_df['variable'],
                            y=local_df['value'],
                            customdata = togg,
                            marker_color = colors[i],
                            hoverinfo="skip",
                            hovertemplate="<br>".join(['<b>%{x} Time: %{y:.1f}%</b>'] + togg_data)))
## for the plot online
    fig.update_layout(
        title='<b>Vehicle States by Experiment</b>',
        title_x = 0.5,
        xaxis_tickfont_size=14,
        template="plotly_white",
        yaxis=dict(
            title='Time in State (%)',
            titlefont_size=16,
            tickfont_size=14,
        ),
        legend=dict(
            bgcolor="white",
            bordercolor="black",
            borderwidth = 1
        ),
        hoverlabel=dict(
            bgcolor="#787b80",
            font_size=12,
            font=dict(color='white')
        ),
        barmode='group',
        bargap=0.15,
        bargroupgap=0.1
    )

enter image description here

As you can see, the original trace name still appears, and is often in the way of the plot, legend, or the bars themselves. I thought that perhaps turning hoverinfo to "skip" would remove the superfluous information, but that hasn't been successful.

Is there a parameter I'm missing which would allow me to turn off this trace label, but leave my tooltip intact?

Red
  • 26,798
  • 7
  • 36
  • 58
  • Hover text labels can be hidden by adding the following tags in the hover template. `hovertemplate="
    ".join(['%{x} Time: %{y:.1f}%'] + togg_data + "")`
    – r-beginners Jun 17 '23 at 02:15
  • See [How to display name in legent but not on hover?](https://stackoverflow.com/a/67637858/2529954) – EricLavault Jun 17 '23 at 13:16

0 Answers0