# Disabling Default Tool Tip on Violin Plot

**URL:** <https://community.plotly.com/t/disabling-default-tool-tip-on-violin-plot/85853>\
**Category:** 📊 Plotly Python\
**Tags:** question\
**Created:** [July 16, 2024, 9:46am UTC](https://community.plotly.com/t/disabling-default-tool-tip-on-violin-plot/85853 "2024-07-16T09:46:54Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![B1jam1](https://avatars.discourse-cdn.com/v4/letter/b/c5a1d2/32.png) [@B1jam1](https://community.plotly.com/u/B1jam1)\
**Post date:** [July 16, 2024, 9:46am UTC](https://community.plotly.com/t/disabling-default-tool-tip-on-violin-plot/85853/1 "2024-07-16T09:46:54Z")

</div>

Hi,

I was wondering if there was a way to have **graphic objects violin plot** not display the trace’s **kde** , **mean** , **median** , **quantiles** etc.  
This information is displayed whenever the mouse is not hovering over a precise data point, even though I have entered a totally different `hovertemplate`, which is displayed when data points are hovered upon.

The unwanted information is shown on the following image:

 ![Violinplot - Unwanted Data](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/5/9/5948d7f62375a1735e46a22f31785e915b0a3124.png)

Thank you for your help!

---

<div class="post-metadata">

**Author:** ![empet](https://avatars.discourse-cdn.com/v4/letter/e/977dab/32.png) [@empet](https://community.plotly.com/u/empet)\
**Post date:** [July 16, 2024, 8:21pm UTC](https://community.plotly.com/t/disabling-default-tool-tip-on-violin-plot/85853/2 "2024-07-16T20:21:39Z")

</div>

@B1jam1 To get help you should give your code (with syntetic data, not the real one) to realize how to set hoverinfo.

---

<div class="post-metadata">

**Author:** ![farispriadi](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/farispriadi/32/26759_2.png) [@farispriadi](https://community.plotly.com/u/farispriadi)\
**Post date:** [July 17, 2024, 12:26am UTC](https://community.plotly.com/t/disabling-default-tool-tip-on-violin-plot/85853/3 "2024-07-17T00:26:52Z")

</div>

Hi @B1jam1 ,

Just wanna link your solution on other post, it seems related to this post.

> [@Disabling default ToolTip while using a HoverTemplate in Python](https://community.plotly.com/t/disabling-default-tooltip-while-using-a-hovertemplate-in-python/85824/4):
>
> 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!

---

<div class="post-metadata">

**Author:** ![B1jam1](https://avatars.discourse-cdn.com/v4/letter/b/c5a1d2/32.png) [@B1jam1](https://community.plotly.com/u/B1jam1)\
**Post date:** [July 17, 2024, 8:40am UTC](https://community.plotly.com/t/disabling-default-tool-tip-on-violin-plot/85853/4 "2024-07-17T08:40:42Z")

</div>

Hi @farispriadi,

It is related but I thought I would open another topic for this subject, since it is specific to violin plots: whereas the previous one was about the trace id being displayed when hovering over the information, this one is about violin plot specific information being displayed when not hovering over the data points but on the trace.  
Hope it made sense to do so.

---

<div class="post-metadata">

**Author:** ![B1jam1](https://avatars.discourse-cdn.com/v4/letter/b/c5a1d2/32.png) [@B1jam1](https://community.plotly.com/u/B1jam1)\
**Post date:** [July 17, 2024, 9:00am UTC](https://community.plotly.com/t/disabling-default-tool-tip-on-violin-plot/85853/5 "2024-07-17T09:00:42Z")

</div>

Sure here is the code:

```auto
def create_violinplot(*args):
    
    fig = go.Figure()
    for column in plot_scaled.columns:
        #Retrieving some data to be displayed for each point: the label it is issued from and if there is an alert
        alert_array = alert_matrix[column].map(lambda a: 'Alert' if a else 'No alert')
        data = np.concatenate(
                                (np.stack(arrays=[labels, alert_array], axis=1), 
                                 np.array([arg[column].map(lambda o: arg.name + 'says YES' if o else arg.name + 'says NO') for arg in args ]).T), # The args are boolean matrices we want to be retrieving data from
                                axis=1)
        
        fig.add_trace(go.Violin(y=df[column],
                                name=column,
                                points='all',
                                pointpos=0,
                                customdata=data,
                                jitter=0.2)        
                        )
        
    hovertemplate = '<extra></extra>Sample %{customdata[0]} <br>%{customdata[1]}'
    #Create the hover template: the three first columns of the customdata are necessarily alocated whereas the following ones depend on the number of arguments
    for i in range(3, len(args)+2):
        hovertemplate += '<br>%{customdata['+str(i)+']}'
        
    #And finally put all of that information in the hovertemplate of the traces
    fig.update_traces(hovertemplate=hovertemplate,
                      showlegend=False)

    
    return fig

```

Now when the cursor hovers over a data point, the hovertemplate is displayed:

![Screenshot (6)](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/f/5/f5605200c5c0f74cc6c0294e8ce745f0eef3194d.png)

However, when the cursor is on or in the vicinity of the violin, it displays this default information which I would like to get rid of:

 ![Violinplot - Unwanted Data](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/7/6/768a60d9525e1bda5d19317e5d3c4dab516909fa.png)

Hope that helps.

Thank you for your help!

---

<div class="post-metadata">

**Author:** ![empet](https://avatars.discourse-cdn.com/v4/letter/e/977dab/32.png) [@empet](https://community.plotly.com/u/empet)\
**Post date:** [July 17, 2024, 2:43pm UTC](https://community.plotly.com/t/disabling-default-tool-tip-on-violin-plot/85853/6 "2024-07-17T14:43:51Z")

</div>

@B1jam1

I’m sorry but I cannot use this function without data.  
To realize what is going on, I need the effective fig definition, to inspect `fig.data`, and deduce why unnecessary information is displayed on hover.

---

<div class="post-metadata">

**Author:** ![farispriadi](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/farispriadi/32/26759_2.png) [@farispriadi](https://community.plotly.com/u/farispriadi)\
**Post date:** [July 18, 2024, 1:16am UTC](https://community.plotly.com/t/disabling-default-tool-tip-on-violin-plot/85853/7 "2024-07-18T01:16:56Z")

</div>

Hi @B1jam1 ,

To hide tooltips when hovering violin (not the point inside), set `hoveron='points'` at all traces using `fig.update_traces`.  
The default value of `hoveron` is ‘violin+points’ that will show the tooltips whenever you hover points or the violin.

```auto
fig.update_traces(hoveron="points")

```

Hope this solve your issue.

---

<div class="post-metadata">

**Author:** ![farispriadi](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/farispriadi/32/26759_2.png) [@farispriadi](https://community.plotly.com/u/farispriadi)\
**Post date:** [July 18, 2024, 7:31am UTC](https://community.plotly.com/t/disabling-default-tool-tip-on-violin-plot/85853/8 "2024-07-18T07:31:19Z")

</div>

Hi @B1jam1 ,

just for curiosity, was the previous post is the solution you are looking for ?

---

<div class="post-metadata">

**Author:** ![B1jam1](https://avatars.discourse-cdn.com/v4/letter/b/c5a1d2/32.png) [@B1jam1](https://community.plotly.com/u/B1jam1)\
**Post date:** [July 18, 2024, 9:24am UTC](https://community.plotly.com/t/disabling-default-tool-tip-on-violin-plot/85853/9 "2024-07-18T09:24:26Z")

</div>

Yes thank you very much @farispriadi you really helped me out a lot!
