Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

plot.ly Hover Box Size attribute

I'm using the plot.ly Python api and cannot figure out how to adjust the size of the plotly hover box size.

For example, in the visualization below the label for CollegeClass.... is truncated. I would like to adjust the length of the string in the hover box.

enter image description here

like image 953
Clayton Avatar asked Mar 24 '16 18:03

Clayton


People also ask

How do you change text size in plotly?

You can set the font size using the update_layout function and specifying the font's size by passing the dictionary in the font parameter.

What is Add_trace in plotly?

Adding Traces To Subplots make_subplots() , then supplying the row and col arguments to add_trace() can be used to add a trace to a particular subplot. In [12]: from plotly.subplots import make_subplots fig = make_subplots(rows=1, cols=2) fig. Scatter(y=[4, 2, 1], mode="lines"), row=1, col=1) fig.

What is an example of the plotly layout attribute?

An example of this would be layout. xaxis. range , which may be specified explicitly, but if not will be computed based on the range of x values for every trace linked to that axis. The JavaScript layer will ignore unknown attributes or malformed values, although the plotly.


2 Answers

I might be a little late but I found a batter solution Adding hoverlabel: {namelength :-1} into my trace object did the trick.

From Here

like image 154
PANDYA TUSHAR Avatar answered Oct 05 '22 23:10

PANDYA TUSHAR


You probably found an answer since but :

By setting 'text' and passing it to your hoverinfo. In your example if you set text='CollegeClass' and set your hoverinfo = 'text' you will get the result you expect. It seems that the name of the trace get truncated while the text or label that you pass isn't.

data = [
go.Scatter(
    x=[0, 1, 2],
    y=[1, 3, 2],
    mode='markers',
    text=['Text A', 'Text B', 'Text C']
    hoverinfo = 'text'
)]

Copied from https://plot.ly/python/text-and-annotations/#adding-hover-text-to-data-in-line-and-scatter-plots Not that in my case I had to set hoverinfo = 'text' while in the example it seems to work without.

like image 35
User18981898198119 Avatar answered Oct 06 '22 01:10

User18981898198119