Skip to content

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

Description

@lyschoening

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?

Activity

  1. etpinard commented on Nov 18, 2015

    @etpinard
    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 .

  2. lyschoening commented on Nov 18, 2015

    @lyschoening
    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.

  3. chriddyp commented on Nov 18, 2015

    @chriddyp
    Member

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

  4. fizcris commented on Aug 8, 2017

    @fizcris

    Is this option available in python offline version?

  5. hadhoryth commented on Nov 1, 2017

    @hadhoryth

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

    Pyplot.plot(data, config={'displayModeBar':False, ....})
    
  6. PabloBotas commented on Jan 22, 2019

    @PabloBotas

    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
  7. etpinard commented on Jan 22, 2019

    @etpinard
    Contributor

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

  8. rageycomma commented on Jan 9, 2020

    @rageycomma

    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.

  9. j-madrone commented on Jul 2, 2020

    @j-madrone

    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
  10. xanderwallace85 commented on Oct 21, 2020

    @xanderwallace85

    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 :(

  11. j-madrone commented on Oct 21, 2020

    @j-madrone

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

  12. xanderwallace85 commented on Oct 21, 2020

    @xanderwallace85

    @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?

  13. j-madrone commented on Oct 21, 2020

    @j-madrone

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

  14. marysteffin commented on Oct 27, 2022

    @marysteffin

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions