Coder Social home page Coder Social logo

Comments (14)

etpinard avatar etpinard commented on May 7, 2024 6

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 .

from plotly.js.

j-madrone avatar j-madrone commented on May 7, 2024 5

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

from plotly.js.

rageycomma avatar rageycomma commented on May 7, 2024 2

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.

from plotly.js.

j-madrone avatar j-madrone commented on May 7, 2024 1

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

from plotly.js.

marysteffin avatar marysteffin commented on May 7, 2024 1

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

Looks like that works for offline plots.

from plotly.js.

lyschoening avatar lyschoening commented on May 7, 2024

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.

from plotly.js.

chriddyp avatar chriddyp commented on May 7, 2024

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

from plotly.js.

fizcris avatar fizcris commented on May 7, 2024

Is this option available in python offline version?

from plotly.js.

hadhoryth avatar hadhoryth commented on May 7, 2024

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

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

from plotly.js.

PabloBotas avatar PabloBotas commented on May 7, 2024

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

from plotly.js.

etpinard avatar etpinard commented on May 7, 2024

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

from plotly.js.

xanderwallace85 avatar xanderwallace85 commented on May 7, 2024

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

from plotly.js.

xanderwallace85 avatar xanderwallace85 commented on May 7, 2024

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

from plotly.js.

j-madrone avatar j-madrone commented on May 7, 2024

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

from plotly.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.