Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable hover information on trace, plotly

Tags:

I'm currently using the plotly service to graph some water quality data. I've added some lines to represent the the various stages of water quality, with them shaded so they are green, yellow, and red.

I've been able to remove some unnecessary lines from the legend, but they still show up when hovering over the data. I've looked here text and annotations but when trying to use the "hoverinfo" parameter, I get a

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

error. Is there an alternative way to doing this for the Scatter plot? So far I've looked and have found nothing too helpful.

Here is how I'm currently trying to set up the trace:

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.

like image 755
ChrisDevWard Avatar asked Aug 31 '15 20:08

ChrisDevWard


People also ask

How do I turn off hover Plotly?

layout = go. Layout(hovermode=False) fig = go.

How do you hide a trace in Plotly?

In order to keep the items visible in the legend but hidden in the plot, you need to set the values to 'legendonly'. The legend entries can then still be clicked to toggle individual visibility.

How do you remove gridlines in Plotly?

Axis grid lines can be disabled by setting the showgrid property to False for the x and/or y axis.


2 Answers

On your trace add: hoverinfo='skip'

trace = dict(              x=[1,2,3,4],              y=[1,2,3,4],              hoverinfo='skip'             ) 
like image 187
Henrique Florencio Avatar answered Sep 28 '22 15:09

Henrique Florencio


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 
like image 39
Shinto Joseph Avatar answered Sep 28 '22 14:09

Shinto Joseph