Show Sidebar Hide Sidebar

Configuration in Python

How to set configuration options of plotly graphs in python. Examples of both online and offline configurations.

Offline Configuration Options

Now you can pass a config dictionary with all configurations options such as scrollZoom, editable, and displayModeBar. For the complete list of config options check out: https://github.com/plotly/plotly.js/blob/master/src/plot_api/plot_config.js

Enable Scroll Zoom
In [1]:
import plotly.graph_objects as go

fig = go.Figure()

fig.add_trace(
    go.Scatter(
        x=[1, 2, 3],
        y=[1, 3, 1]))

fig.show(config={'scrollZoom': True})
Display ModeBar
In [2]:
import plotly.graph_objects as go

fig = go.Figure()

fig.add_trace(
    go.Scatter(
        x=[1, 2, 3],
        y=[1, 3, 1]))

fig.show(config={'displayModeBar': True})
Edit Mode - change the title and axis titles
In [3]:
import plotly.graph_objects as go

fig = go.Figure()

fig.add_trace(
    go.Scatter(
        x=[1, 2, 3],
        y=[1, 3, 1]))

fig.show(config={'editable': True})
Multiple Config Options at Once!
In [4]:
import plotly.graph_objects as go

fig = go.Figure()

fig.add_trace(
    go.Scatter(
        x=[1, 2, 3],
        y=[1, 3, 1]))

fig.show(config={
    'scrollZoom': True,
    'displayModeBar': True,
    'editable': True
})
Remove Modebar Buttons
In [5]:
import plotly.graph_objects as go

fig = go.Figure()

fig.add_trace(
    go.Scatter(
        x=[1, 2, 3],
        y=[1, 3, 1]))

fig.show(config={
    'modeBarButtonsToRemove': ['toggleSpikelines','hoverCompareCartesian']
})

Reference