Skip to content

Latest commit

 

History

History
141 lines (106 loc) · 2.95 KB

configuration-options.md

File metadata and controls

141 lines (106 loc) · 2.95 KB
jupyter
jupytext kernelspec language_info plotly
notebook_metadata_filter text_representation
all
extension format_name format_version jupytext_version
.md
markdown
1.1
1.2.1
display_name language name
Python 3
python
python3
codemirror_mode file_extension mimetype name nbconvert_exporter pygments_lexer version
name version
ipython
3
.py
text/x-python
python
python
ipython3
3.7.3
description display_as language layout name order page_type permalink thumbnail
How to set configuration options of plotly graphs in python.
file_settings
python
base
Configuration
9
u-guide
python/configuration-options/
thumbnail/modebar-icons.png

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
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
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
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!
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
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']
})

Double-click Delay

Sets the maximum delay between two consecutive clicks to be interpreted as a double-click in ms. This is the time interval between first mousedown, and' second mouseup. The default timing is 300 ms (less than half a second). This setting propagates to all on-subplot double clicks (except for geo and mapbox).

import plotly.graph_objects as go

fig = go.Figure(go.Bar(
    y = [3, 5, 3, 2],
    x = ["2019-09-02", "2019-10-10", "2019-11-12", "2019-12-22"],
    texttemplate = "%{label}",
    textposition = "inside"))

fig.update_layout(xaxis = {'type': 'date'})

fig.show(config = {'doubleClickDelay': 1000})

Reference

See config options at https://github.com/plotly/plotly.js/blob/master/src/plot_api/plot_config.js#L6