You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description: How to set configuration options of plotly graphs in python.
25
+
description: How to set the configuration options of figures using the Plotly
26
+
Python graphing library.
26
27
display_as: file_settings
27
28
language: python
28
29
layout: base
@@ -33,74 +34,192 @@ jupyter:
33
34
thumbnail: thumbnail/modebar-icons.png
34
35
---
35
36
37
+
# Configuration Options
36
38
37
-
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
39
+
The `.show()` method that you use to display your figures also accepts a `config` parameter.
38
40
39
-
##### Enable Scroll Zoom
41
+
You can set the configuration options for your figure by passing a dictionary to this parameter which contains the options you want to set.
42
+
43
+
If you don't set an option's value, it will be automatically be set to the default value for that option.
44
+
45
+
For the complete list of configuration options and their defaults see: https://github.com/plotly/plotly.js/blob/master/src/plot_api/plot_config.js
46
+
47
+
##### Enabling Scroll Zoom
48
+
49
+
This option allows users to zoom in and out of figures using the scroll wheel on their mouse and/or a two-finger scroll.
40
50
41
51
```python
42
52
import plotly.graph_objects as go
43
53
44
54
fig = go.Figure()
45
55
56
+
config =dict({'scrollZoom': True})
57
+
46
58
fig.add_trace(
47
59
go.Scatter(
48
60
x=[1, 2, 3],
49
61
y=[1, 3, 1]))
50
62
51
-
fig.show(config={'scrollZoom': True})
63
+
fig.show(config=config)
52
64
```
53
65
54
-
##### Display ModeBar
66
+
##### Forcing The Modebar to Always Be Visible
67
+
68
+
When users hover over a figure generated with plotly.py, a modebar appears in the top-right of the figure. This presents users with several options for interacting with the figure.
69
+
70
+
By default, the modebar is only visible while the user is hovering over the chart. If you would like the modebar to always be visible regardless of whether or not the user is currently hovering over the figure, set the displayModeBar attribute in the configuration of your figure to true.
55
71
56
72
```python
57
73
import plotly.graph_objects as go
58
74
59
75
fig = go.Figure()
60
76
77
+
config = {'displayModeBar': True}
78
+
61
79
fig.add_trace(
62
80
go.Scatter(
63
81
x=[1, 2, 3],
64
82
y=[1, 3, 1]))
65
83
66
-
fig.show(config={'displayModeBar': True})
84
+
fig.show(config=config)
67
85
```
68
86
69
-
##### Edit Mode - change the title and axis titles
87
+
##### Preventing the Modebar from Appearing
88
+
89
+
When users hover over a figure generated with `plotly.py`, a modebar appears in the top-right of the figure. This presents users with several options for interacting with the figure.
90
+
91
+
By default, the modebar is only visible while the user is hovering over the chart. If you would like the modebar to never be visible, then set the `displayModeBar` attribute in the config of your figure to false.
70
92
71
93
```python
72
94
import plotly.graph_objects as go
73
95
74
96
fig = go.Figure()
75
97
98
+
config = {'displayModeBar': False}
99
+
76
100
fig.add_trace(
77
101
go.Scatter(
78
102
x=[1, 2, 3],
79
103
y=[1, 3, 1]))
80
104
81
-
fig.show(config={'editable': True})
105
+
fig.show(config=config)
82
106
```
83
107
84
-
##### Multiple Config Options at Once!
108
+
109
+
##### Hiding the Plotly Logo on the Modebar
85
110
86
111
```python
87
112
import plotly.graph_objects as go
88
113
89
114
fig = go.Figure()
90
115
116
+
config = {'displaylogo': False}
117
+
91
118
fig.add_trace(
92
119
go.Scatter(
93
120
x=[1, 2, 3],
94
121
y=[1, 3, 1]))
95
122
96
-
fig.show(config={
123
+
fig.show(config=config)
124
+
```
125
+
126
+
##### Turning Off Responsiveness
127
+
128
+
By default, figures you create with the `plotly.py` package are [responsive](https://en.wikipedia.org/wiki/Responsive_web_design). Responsive figures automatically change their height and width when the size of the window they are displayed in changes. This is true for figures which are displayed in web browsers on desktops and mobile, Jupyter Notebooks, and other [rendering](https://plot.ly/python/renderers/) environments.
129
+
130
+
Try resizing your browser window to see this behavior in effect on this page.
131
+
132
+
If you would like to disable this default behavior and force your figures to always have the same height and width regardless of the window size, set the value of the `responsive` key to `False` in your figure's configuration dictionary.
133
+
134
+
```python
135
+
import plotly.graph_objects as go
136
+
137
+
fig = go.Figure()
138
+
139
+
config = {'responsive': False}
140
+
141
+
fig.add_trace(
142
+
go.Scatter(
143
+
x=[1, 2, 3],
144
+
y=[1, 3, 1]))
145
+
146
+
fig.show(config=config)
147
+
```
148
+
149
+
##### Making A Static Chart
150
+
151
+
```python
152
+
import plotly.graph_objects as go
153
+
154
+
fig = go.Figure()
155
+
156
+
config = {'staticPlot': True}
157
+
158
+
fig.add_trace(
159
+
go.Scatter(
160
+
x=[1, 2, 3],
161
+
y=[1, 3, 1]))
162
+
163
+
fig.show(config=config)
164
+
```
165
+
166
+
##### Customizing Download Plot Options
167
+
168
+
```python
169
+
import plotly.graph_objects as go
170
+
171
+
fig = go.Figure()
172
+
173
+
config = {
174
+
'toImageButtonOptions': {
175
+
'format': 'svg', # one of png, svg, jpeg, webp
176
+
'filename': 'custom_image',
177
+
'height': 500,
178
+
'width': 700,
179
+
'scale': 1# Multiply title/legend/axis/canvas sizes by this factor
The dictionary that you use to specify configuration options for your figures can contain more than one configuration key/value pair.
194
+
195
+
```python
196
+
import plotly.graph_objects as go
197
+
198
+
fig = go.Figure()
199
+
200
+
config =dict({
97
201
'scrollZoom': True,
98
202
'displayModeBar': True,
99
203
'editable': True
100
204
})
205
+
206
+
fig.add_trace(
207
+
go.Scatter(
208
+
x=[1, 2, 3],
209
+
y=[1, 3, 1]))
210
+
211
+
fig.show(config=config)
101
212
```
102
213
103
-
##### Remove Modebar Buttons
214
+
##### Removing Modebar Buttons
215
+
216
+
To delete buttons from the modebar, pass an array of strings containing the names of the buttons you want to remove to the `modeBarButtonsToRemove` attribute in the figure's configuration dictionary. Note that different chart types have different default modebars. The following is a list of all the modebar buttons and the chart types they are associated with:
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).
122
-
This setting propagates to all on-subplot double clicks (except for geo and mapbox).
239
+
### Double-Click Delay
240
+
Sets the maximum delay between two consecutive clicks to be interpreted as a double-click in milliseconds. This is the time interval between first mousedown and second mouseup. The default timing is 300 ms (less than half a second).
241
+
This setting propagates to all on-subplot double clicks (except for `geo` and `mapbox`).
The same configuration dictionary that you pass to the `config` parameter of the `show()` method can also be passed to the [`config` property of a `dcc.Graph` component](https://dash.plotly.com/dash-core-components/graph).
262
+
263
+
#### Reference
140
264
141
265
See config options at https://github.com/plotly/plotly.js/blob/master/src/plot_api/plot_config.js#L6
0 commit comments