Repository navigation
question: Is it possible to disable interaction with a plot? #15
Description
Activity
This can be done using one of
Plotly.plot's (currently poorly documented) config arguments.The full list is found here: https://github.com/plotly/plotly.js/blob/master/src/plot_api/plot_config.jshttps://github.com/plotly/plotly.js/blob/master/src/plot_api/plot_config.js
Plotly.plot(graphDiv, data, layout, {staticPlot: true})
should do the trick.
Moreover, note that in svg 2d plots, individual axis can be made fixed using the
fixedrangeattribute: https://github.com/plotly/plotly.js/blob/master/src/plots/cartesian/layout_attributes.js#L84 .Reacted by Niyamat Ullah, Toomas, Iddan Aaronsohn, Samuel Earl and Matěj TrnkaReacted by Jordan Ashley CrawThank you for pointing me to the code for this. I can see there's also a
displayModeBaroption, so that answers all my questions.FYI, here are some examples of most of the configuration options: https://plot.ly/javascript/configuration-options/
Is this option available in python offline version?
Yes, for python is also possible, just pass "config" dict to the plot.
Pyplot.plot(data, config={'displayModeBar':False, ....})Can this be done for a specific trace?
There might be a better approach for what I want:
- as trace0 lot of scatter points as background without interactivity or legend
- as trace1, some selected subset with full interactivity
@PabloBotas you can adding your own custom legend click handlers. See #2581
If you pass
staticPlot: true, you can't disable it. So if you're creating a plot and want to disable it until data is received, even if you passstaticPlot: falseafterwards, data doesn't update. So, this doesn't really resolve the issue of disabling user interaction for plots that are updated frequently.Reacted by usser123 and laurenIn case anyone comes looking for this feature like I did for Choropleth plots:
- The option to disable panning:
dragMode=Falsein the layout property - The option to disable scrolling:
scrollZoom=Falsein the config property - The option to disable map controls:
displayModeBar=Falsein the config property
Reacted by Daniel Tkach and Philipp ScheerReacted by Daniel TkachReacted by Daniel TkachReacted by Daniel Tkach and Philipp ScheerReacted by Daniel Tkach- The option to disable panning:
In case anyone comes looking for this feature like I did for Choropleth plots:
- The option to disable panning:
dragMode=Falsein the layout property - The option to disable scrolling:
scrollZoom=Falsein the config property - The option to disable map controls:
displayModeBar=Falsein the config property
Hi @jaspersardonicus ! Which module did you use for the Choropleth map? When relying on plotly.express dragMode=False throws an error when placed in the layout :(
- The option to disable panning:
@xanderwallace85 I used
from plotly import graph_objects as goand constructed the map withfig = go.Choropleth()Reacted by Flavio Camarrone@xanderwallace85 I used
from plotly import graph_objects as goand constructed the map withfig = go.Choropleth()@jaspersardonicus Thanks! Have you also tried to disable pan/drag with plotly.express?
Not yet. I haven't even used plotly.express yet, sorry!
fig.show(config=dict({'staticPlot':True}))Looks like that works for offline plots.
Reacted by E-Tiger Studio
I understand that the interactivity of Plotly is one of the things that make it so powerful, but there are a few situations when a static plot might be preferable. Are there ways to toggle (a) visibility of the modebar and (b) panning/zooming?