Skip to content

question: Is it possible to disable interaction with a plot? #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
lyschoening opened this issue Nov 18, 2015 · 14 comments
Closed

question: Is it possible to disable interaction with a plot? #15

lyschoening opened this issue Nov 18, 2015 · 14 comments

Comments

@lyschoening
Copy link

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?

@etpinard
Copy link
Contributor

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 fixedrange attribute: https://github.com/plotly/plotly.js/blob/master/src/plots/cartesian/layout_attributes.js#L84 .

@lyschoening
Copy link
Author

Thank you for pointing me to the code for this. I can see there's also a displayModeBar option, so that answers all my questions.

@chriddyp
Copy link
Member

FYI, here are some examples of most of the configuration options: https://plot.ly/javascript/configuration-options/

@fizcris
Copy link

fizcris commented Aug 8, 2017

Is this option available in python offline version?

@hadhoryth
Copy link

hadhoryth commented Nov 1, 2017

Yes, for python is also possible, just pass "config" dict to the plot.

Pyplot.plot(data, config={'displayModeBar':False, ....})

@PabloBotas
Copy link

Can this be done for a specific trace?

There might be a better approach for what I want:

  1. as trace0 lot of scatter points as background without interactivity or legend
  2. as trace1, some selected subset with full interactivity

@etpinard
Copy link
Contributor

@PabloBotas you can adding your own custom legend click handlers. See #2581

@rageycomma
Copy link

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 pass staticPlot: false afterwards, data doesn't update. So, this doesn't really resolve the issue of disabling user interaction for plots that are updated frequently.

@j-madrone
Copy link

In case anyone comes looking for this feature like I did for Choropleth plots:

  • The option to disable panning: dragMode=False in the layout property
  • The option to disable scrolling: scrollZoom=False in the config property
  • The option to disable map controls: displayModeBar=False in the config property

@xanderwallace85
Copy link

xanderwallace85 commented Oct 21, 2020

In case anyone comes looking for this feature like I did for Choropleth plots:

  • The option to disable panning: dragMode=False in the layout property
  • The option to disable scrolling: scrollZoom=False in the config property
  • The option to disable map controls: displayModeBar=False in 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 :(

@j-madrone
Copy link

@xanderwallace85 I used from plotly import graph_objects as go and constructed the map with fig = go.Choropleth()

@xanderwallace85
Copy link

@xanderwallace85 I used from plotly import graph_objects as go and constructed the map with fig = go.Choropleth()

@jaspersardonicus Thanks! Have you also tried to disable pan/drag with plotly.express?

@j-madrone
Copy link

Not yet. I haven't even used plotly.express yet, sorry!

@marysteffin
Copy link

fig.show(config=dict({'staticPlot':True}))

Looks like that works for offline plots.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants