Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to disable hover bar / mode bar in plotly.py?

Tags:

python

plotly

so using the bare minimum code to produce a chart in plotly.py:

from plotly.offline import plot
from plotly.graph_objs import Scatter
plot([Scatter(x=[1, 2, 3, 4, 5], y=[3, 2, 1, 2, 3])])

produces a nice chart with a modebar on top of it. I would like to embed my chart in a website where the bar seems really intrusive. In plotly.js there's a really simple way to disable to modebar as shown here. The solution in plotly.js is merely giving additional parameter: Plotly.newPlot('myDiv', data, layout, {displayModeBar: false});

I know there's a way to save static image from plotly where the modebar is obviously disabled, but that would lose the interactive hover-actions on the plot itself, which are useful, whereas the bar that comes with it is not really that useful in my case. What I'm wondering is if there's a way to do remove the modebar in a similiar fashion to how plotly.js works?

One solution, I suppose would be to always go through the produced HTML-file and add every part of the hover bar to r.modeBarButtonsToRemove, which could turn troublesome in the long run.

like image 984
Christian W. Avatar asked Oct 19 '16 08:10

Christian W.


People also ask

How do I hide plotly toolbar?

Just add displayModeBar: false to the config object and it will disable the floating toolbar in Plotly.

How do I remove a Modebar in plotly?

Preventing the Modebar from Appearing By default, the modebar is only visible while the user is hovering over the chart. If you would like the modebar to never be visible, then set the displayModeBar attribute in the config of your figure to false.

How do you remove gridlines in plotly?

Toggling Axis grid lines Axis grid lines can be disabled by setting the showgrid property to False for the x and/or y axis. Here is an example of setting showgrid to False in the graph object figure constructor.


2 Answers

I've been able to do it using the config key word argument, like this:

graph = py.plot(
                figure,
                output_type='div',
                auto_open=False,
                show_link=False,
                config=dict(
                    displayModeBar=False
                )
            )
like image 135
jrm16020 Avatar answered Sep 20 '22 02:09

jrm16020


I am a little late here. But just a side note, this won't disable the functions of the top bar so when you hover it will still zoom and pan (which is extremely annoying on plots that are viewed from a mobile device). But making it a static plot isn't a good solution because I still want users on a computer to be able to hover over the points on the plot.

I solved this by changing two of the figure layout settings. xaxis_fixedrange and yaxis_fixedrange need to be set to True if you want to disable zooming.

like image 43
mitchell Avatar answered Sep 20 '22 02:09

mitchell