# Re-size hover info box

**URL:** https://community.plotly.com/t/re-size-hover-info-box/955
**Category:** 📊 Plotly Python
**Created:** [April 30, 2016, 1:31pm UTC](https://community.plotly.com/t/re-size-hover-info-box/955 "2016-04-30T13:31:31Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![starhammer](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/starhammer/32/240_2.png) [@starhammer](https://community.plotly.com/u/starhammer)
#### Post date: [April 30, 2016, 1:31pm UTC](https://community.plotly.com/t/re-size-hover-info-box/955/1 "2016-04-30T13:31:31Z")

</div>

Hi

Is it possible to re-size the hover info box? Currently I am using the hoverinfo = ‘name’ option and some of my longer trace names are being truncated when hovering.

Thanks

---

<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: [May 1, 2016, 10:18am UTC](https://community.plotly.com/t/re-size-hover-info-box/955/2 "2016-05-01T10:18:01Z")

</div>

To display a longer text at hover, define a list of strings for each point, and set hoverinfo=‘text’.  
See the example below:

```
import plotly.plotly as py
from plotly.graph_objs import *
X=[2, 3.154, 4]
Y=[5.07, 1, 3]
text=['a very long long text: '+'('+'{:.3f}'.format(X[k])+', '+'{:.3f}'.format(Y[k])+')' for k in range(len(X))]
data=Data([
      Scatter(x=X, 
                  y=Y, 
                 mode='markers', 
                 marker=dict(size=8), 
                 name='',
                 text=text, 
                hoverinfo='text')])
 layout=Layout(width=600, 
                       height=600, 
                       showlegend=False,
                       hovermode='closest')
 fig=Figure(data=data, layout=layout)
```

---

<div class="post-metadata">

### Author: ![starhammer](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/starhammer/32/240_2.png) [@starhammer](https://community.plotly.com/u/starhammer)
#### Post date: [May 1, 2016, 11:07am UTC](https://community.plotly.com/t/re-size-hover-info-box/955/3 "2016-05-01T11:07:03Z")

</div>

Hi empet

Thank you for the reply

However, I am already using the text parameter to display other values.

i.e. I have bubbles with ‘markers+text’ with the ‘text’ parameter showing a value annotated on the bubble, and want to use the trace ‘name’ parameter to label each bubble as I show in the graph below.

[https://plot.ly/~starhammer/1267/upremier-league-uchampionship-uleague-1-uleague-2-unational-league-unational-lea/](https://plot.ly/~starhammer/1267/upremier-league-uchampionship-uleague-1-uleague-2-unational-league-unational-lea/)

One solution would be to use annotations rather than ‘markers+text’ to overlay to bubble values on the bubbles. This would free up the ‘text’ parameter for the bubble label as you suggested. But I wanted to avoid that and see if the hover info box could be increased in size.

Thanks  
David

---

<div class="post-metadata">

### Author: ![Mounika](https://avatars.discourse-cdn.com/v4/letter/m/b4bc9f/32.png) [@Mounika](https://community.plotly.com/u/Mounika)
#### Post date: [February 10, 2017, 7:08pm UTC](https://community.plotly.com/t/re-size-hover-info-box/955/4 "2017-02-10T19:08:43Z")

</div>

Hi David,

I have the same issue. I would like to know if you found a go around hack for this.

Thanks,  
Mounika

---

<div class="post-metadata">

### Author: ![Vivekanand](https://avatars.discourse-cdn.com/v4/letter/v/9f8e36/32.png) [@Vivekanand](https://community.plotly.com/u/Vivekanand)
#### Post date: [November 16, 2017, 10:06pm UTC](https://community.plotly.com/t/re-size-hover-info-box/955/5 "2017-11-16T22:06:52Z")

</div>

Guys, is there a resolution for long text hover values being wrapped ? This has become a gating item for my work now. ☹

---

<div class="post-metadata">

### Author: ![Vivekanand](https://avatars.discourse-cdn.com/v4/letter/v/9f8e36/32.png) [@Vivekanand](https://community.plotly.com/u/Vivekanand)
#### Post date: [November 21, 2017, 1:53am UTC](https://community.plotly.com/t/re-size-hover-info-box/955/6 "2017-11-21T01:53:03Z")

</div>

Hi , do we have any more help on this issue ?

---

<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: [November 21, 2017, 3:28pm UTC](https://community.plotly.com/t/re-size-hover-info-box/955/7 "2017-11-21T15:28:50Z")

</div>

@Vivekanand You can insert a few lines of text for each trace. Hover the mouse on the tree leafs in this plot:  
[https://plot.ly/~empet/14679](https://plot.ly/~empet/14679)

This is the code for setting up the text to be displayed on hover over leafs:

```
text=[clade.name for clade in tree.find_clades(order='level')]
for k, strain in enumerate(df['Strain']):
    i=text.index(strain)
    text[i]=text[i]+'<br>Country: '+'{:s}'.format(df.loc[k, 'Country'])+'<br>Region: '+'{:s}'.format(df.loc[k, 'Region'])+\
    '<br>Collection date: '+'{:s}'.format(df.loc[k,'Date'])+\
    '<br>Journal: '+'{:s}'.format(df.loc[k, 'Journal'])+'<br>Authors: '+'{:s}'.format(df.loc[k, 'Authors'])

```

Hence using the html `<br>` tag you can insert as many lines of text as you want.

Moreover, now you can set in a trace:

```
 hoverinfo= "name+x+text"

```

or “name+x+y+text”, etc

---

<div class="post-metadata">

### Author: ![Vivekanand](https://avatars.discourse-cdn.com/v4/letter/v/9f8e36/32.png) [@Vivekanand](https://community.plotly.com/u/Vivekanand)
#### Post date: [November 22, 2017, 2:35pm UTC](https://community.plotly.com/t/re-size-hover-info-box/955/8 "2017-11-22T14:35:32Z")

</div>

@empet , thanks a lot for the reply. From your original comments, I had already figured out the (“br”) trick to show multiple lines in the hover box. Thanks for that 🙂 But because of the nature of data, I have really long texts to be displayed, and the hover box is truncating some parts of the lines, I checked in the plot you suggested and I was able to find a similar data point with similar behaviors, Also we can see that the hover box is masking the datapoint itself,. So is there a way to handle the size of the hover box explicitly and to control the transparency of the box. Please find snapshot of the plot attached .

 ![hover_long_text](https://us1.discourse-cdn.com/flex024/uploads/plot/original/2X/6/6a7e2b537bd6bcccf46603529d920a7860215d28.PNG)

---

<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: [November 22, 2017, 3:53pm UTC](https://community.plotly.com/t/re-size-hover-info-box/955/9 "2017-11-22T15:53:48Z")

</div>

@Vivekanand  
You could split a too long string, testing before including it in the text list whether its length is greater than some threshold. If it is, then split it into two strings, inserting a `<br>` tag at the nearest white space to the half of the initial string.

To set the transparency of the hover label box, insert the key hoverlabel in the definition of a trace:

```
   trace=dict(type='scatter',
              x=x, y=y,
              mode='markers',
              marker=dict(size=4, color='rgb(188, 20, 26)'),
              text=['aaaaaaaa', 'bbbbbbbbb'],
              hoverlabel=dict(bgcolor='rgba(188, 20, 26, 0.5)'),
              hoverinfo='text')
```

---

<div class="post-metadata">

### Author: ![ericmmas](https://avatars.discourse-cdn.com/v4/letter/e/3be4f8/32.png) [@ericmmas](https://community.plotly.com/u/ericmmas)
#### Post date: [November 22, 2017, 6:13pm UTC](https://community.plotly.com/t/re-size-hover-info-box/955/10 "2017-11-22T18:13:54Z")

</div>

Is there any way that you can help me with my hover text on my atlas map. The text is way too long and won’t wrap. If I can get it on multiple lines the viewer could read it. But I am not technically savvy and have no idea how to solve the problem. If you could help, I would be extremely appreciative. My map is:

[https://plot.ly/~ericmmas/57/](https://plot.ly/%7Eericmmas/57/)

Thanks so much!!!

---

<div class="post-metadata">

### Author: ![mpfig](https://avatars.discourse-cdn.com/v4/letter/m/e19b73/32.png) [@mpfig](https://community.plotly.com/u/mpfig)
#### Post date: [October 6, 2018, 10:38am UTC](https://community.plotly.com/t/re-size-hover-info-box/955/11 "2018-10-06T10:38:52Z")

</div>

try using using `hoverlabel = dict(namelength = -1)` instead

example:

```auto
line = dict(type='scatter',
                x = x_vector,
                y = y_vector,
                mode = 'lines+markers',
                name = base.columns[i],
                hoverlabel = dict(namelength = -1)
               )

```

![59](https://us1.discourse-cdn.com/flex024/uploads/plot/original/2X/a/a549bb14776b79b421966a6b904614959fe9f34e.png)

---

<div class="post-metadata">

### Author: ![matanster](https://avatars.discourse-cdn.com/v4/letter/m/b19c9b/32.png) [@matanster](https://community.plotly.com/u/matanster)
#### Post date: [October 21, 2018, 7:19pm UTC](https://community.plotly.com/t/re-size-hover-info-box/955/12 "2018-10-21T19:19:42Z")

</div>

like mpfig posted, this solves it for me:

> hoverlabel = dict(namelength = -1)
