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 Ploty's Python
26
+
graphing library.
26
27
display_as: file_settings
27
28
language: python
28
29
layout: base
@@ -33,40 +34,150 @@ 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.
40
+
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
38
46
39
47
##### Enable Scroll Zoom
40
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.
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
+
##### Force 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
+
##### Never Display The Modebar
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.
92
+
93
+
```python
94
+
import plotly.graph_objects as go
95
+
96
+
fig = go.Figure()
97
+
98
+
config = {'displayModeBar': False}
99
+
100
+
fig.add_trace(
101
+
go.Scatter(
102
+
x=[1, 2, 3],
103
+
y=[1, 3, 1]))
104
+
105
+
fig.show(config=config)
106
+
```
107
+
108
+
##### Display the `Edit Chart` Link
109
+
110
+
Set `showLink` to `True` in order to make your figure editable on [Chart Studio](https://plot.ly/online-chart-maker).
111
+
112
+
```python
113
+
import plotly.graph_objects as go
114
+
115
+
fig = go.Figure()
116
+
117
+
config = {'showLink': True}
118
+
119
+
fig.add_trace(
120
+
go.Scatter(
121
+
x=[1, 2, 3],
122
+
y=[1, 3, 1]))
123
+
124
+
fig.show(config=config)
125
+
```
126
+
127
+
### Display The `Edit In Chart Studio` Modebar Button
128
+
129
+
```python
130
+
import plotly.graph_objects as go
131
+
132
+
fig = go.Figure()
133
+
134
+
config = {'showEditInChartStudio': True}
135
+
136
+
fig.add_trace(
137
+
go.Scatter(
138
+
x=[1, 2, 3],
139
+
y=[1, 3, 1]))
140
+
141
+
fig.show(config=config)
142
+
```
143
+
144
+
##### Hide the Plotly Logo on the Modebar
145
+
146
+
```python
147
+
import plotly.graph_objects as go
148
+
149
+
fig = go.Figure()
150
+
151
+
config = {'displaylogo': False}
152
+
153
+
fig.add_trace(
154
+
go.Scatter(
155
+
x=[1, 2, 3],
156
+
y=[1, 3, 1]))
157
+
158
+
fig.show(config=config)
159
+
```
160
+
161
+
##### Making A Responsive Chart
162
+
163
+
```python
164
+
import plotly.graph_objects as go
165
+
166
+
fig = go.Figure()
167
+
168
+
config = {'responsive': True}
169
+
170
+
fig.add_trace(
171
+
go.Scatter(
172
+
x=[1, 2, 3],
173
+
y=[1, 3, 1]))
174
+
175
+
fig.show(config=config)
176
+
```
177
+
178
+
##### Editable Mode
179
+
180
+
In editable mode, users can edit the chart title, axis labels and trace names in the legend.
70
181
71
182
```python
72
183
import plotly.graph_objects as go
@@ -81,27 +192,81 @@ fig.add_trace(
81
192
fig.show(config={'editable': True})
82
193
```
83
194
84
-
##### Multiple Config Options at Once!
195
+
##### Making A Static Chart
85
196
86
197
```python
87
198
import plotly.graph_objects as go
88
199
89
200
fig = go.Figure()
90
201
202
+
config = {'staticPlot': True}
203
+
91
204
fig.add_trace(
92
205
go.Scatter(
93
206
x=[1, 2, 3],
94
207
y=[1, 3, 1]))
95
208
96
-
fig.show(config={
209
+
fig.show(config=config)
210
+
```
211
+
212
+
##### Customize Download Plot Options
213
+
214
+
```python
215
+
import plotly.graph_objects as go
216
+
217
+
fig = go.Figure()
218
+
219
+
config = {
220
+
'toImageButtonOptions': {
221
+
'format': 'svg', # one of png, svg, jpeg, webp
222
+
'filename': 'custom_image',
223
+
'height': 500,
224
+
'width': 700,
225
+
'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.
240
+
241
+
```python
242
+
import plotly.graph_objects as go
243
+
244
+
fig = go.Figure()
245
+
246
+
config =dict({
97
247
'scrollZoom': True,
98
248
'displayModeBar': True,
99
249
'editable': True
100
250
})
251
+
252
+
fig.add_trace(
253
+
go.Scatter(
254
+
x=[1, 2, 3],
255
+
y=[1, 3, 1]))
256
+
257
+
fig.show(config=config)
101
258
```
102
259
103
260
##### Remove Modebar Buttons
104
261
262
+
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).
285
+
### Double Click Delay
286
+
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).
287
+
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` parameter of a `dcc.Graph` component.
0 commit comments