Disable trace pointer information

I am currently using the plotly service to chart some water quality data. I added a few lines to represent the various stages of water quality, with their shading, so that they are green, yellow and red.

I managed to remove some unnecessary lines from the legend, but they still appear when you hover over the data. I looked at the text and annotations here, but when I try to use the "hoverinfo" parameter, I get

"plotly.exceptions.PlotlyDictKeyError: Invalid key, 'hoverinfo', for class, 'Scatter'."

error. Is there an alternative way to do this for a Scatter plot? So far I looked and found nothing too useful.

This is how I am trying to set up the trace now:

badNTULevel = Scatter(                                                                              
x=[],                                                                                           
y=[100],                                                                                        
mode='lines',                                                                                   
line=Line(                                                                                      
    opacity=0.5,                                                                                
    color='rgb(253,172,79)',                                                                    
    width=1,                                                                                    
),                                                                                              
stream=Stream(                                                                                  
    token=stream_ids[3],                                                                        
    maxpoints=80                                                                                
),                                                                                              
hoverinfo='none',                                                                               
fill='tonexty',                                                                                 
name="Water Treatment Plants Can't Process over 100"
)                                        

Any help would be appreciated.

+5
source share
3 answers
from plotly.offline import plot
import plotly.graph_objs as go

def spline(x_axis,loop):

     trace = go.Scatter(
        x = x_axis,
        y = loop[i],
        fill = 'tonexty',
        mode ='lines',
        showlegend = False,
        hoverinfo='none'
        )

    data = [trace]



    layout = go.Layout(
        title='Graph title here',
        height=600,
        xaxis=dict(
            autorange=True
        ),
        yaxis=dict(
            autorange=True
        )
    )
    fig = go.Figure(data=data, layout=layout)
    # plot(fig, filename='spline.html')
    plot_div = plot(fig, output_type='div', include_plotlyjs=False)
    return plot_div
+2
source

A more universal solution would be to set the Layout 'hovermode' property as follows:

#...
layout = go.Layout(hovermode=False)
fig = go.Figure(data=data, layout=layout)
#...

Python link here: https://plot.ly/python/reference/#layout

NB. This will turn off the text when you hover over all the traces associated with this layout ... May not match the desired behavior.

0
source

In your wake add: hoverinfo = 'skip'

trace = dict(
             x=[1,2,3,4],
             y=[1,2,3,4],
             hoverinfo='skip'
            )
0
source

All Articles