Skip to content

Commit d6d0f00

Browse files
author
Joseph Damiba
committed
Revert "add examples for configuration options"
This reverts commit 34faa1c.
1 parent 34faa1c commit d6d0f00

File tree

1 file changed

+15
-227
lines changed

1 file changed

+15
-227
lines changed

doc/python/configuration-options.md

+15-227
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ jupyter:
55
text_representation:
66
extension: .md
77
format_name: markdown
8-
format_version: '1.2'
9-
jupytext_version: 1.3.2
8+
format_version: '1.1'
9+
jupytext_version: 1.2.1
1010
kernelspec:
1111
display_name: Python 3
1212
language: python
@@ -20,10 +20,9 @@ jupyter:
2020
name: python
2121
nbconvert_exporter: python
2222
pygments_lexer: ipython3
23-
version: 3.7.0
23+
version: 3.7.3
2424
plotly:
25-
description: How to set the configuration options of figures using Ploty's Python
26-
graphing library.
25+
description: How to set configuration options of plotly graphs in python.
2726
display_as: file_settings
2827
language: python
2928
layout: base
@@ -34,150 +33,40 @@ jupyter:
3433
thumbnail: thumbnail/modebar-icons.png
3534
---
3635

37-
# Configuration Options
3836

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
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
4638

4739
##### Enable Scroll Zoom
4840

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-
5141
```python
5242
import plotly.graph_objects as go
5343

5444
fig = go.Figure()
5545

56-
config = dict({'scrollZoom': True})
57-
5846
fig.add_trace(
5947
go.Scatter(
6048
x=[1, 2, 3],
6149
y=[1, 3, 1]))
6250

63-
fig.show(config=config)
51+
fig.show(config={'scrollZoom': True})
6452
```
6553

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.
54+
##### Display ModeBar
7155

7256
```python
7357
import plotly.graph_objects as go
7458

7559
fig = go.Figure()
7660

77-
config = {'displayModeBar': True}
78-
7961
fig.add_trace(
8062
go.Scatter(
8163
x=[1, 2, 3],
8264
y=[1, 3, 1]))
8365

84-
fig.show(config=config)
66+
fig.show(config={'displayModeBar': True})
8567
```
8668

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.
69+
##### Edit Mode - change the title and axis titles
18170

18271
```python
18372
import plotly.graph_objects as go
@@ -192,81 +81,27 @@ fig.add_trace(
19281
fig.show(config={'editable': True})
19382
```
19483

195-
##### Making A Static Chart
196-
197-
```python
198-
import plotly.graph_objects as go
199-
200-
fig = go.Figure()
201-
202-
config = {'staticPlot': True}
203-
204-
fig.add_trace(
205-
go.Scatter(
206-
x=[1, 2, 3],
207-
y=[1, 3, 1]))
208-
209-
fig.show(config=config)
210-
```
211-
212-
##### Customize Download Plot Options
84+
##### Multiple Config Options at Once!
21385

21486
```python
21587
import plotly.graph_objects as go
21688

21789
fig = go.Figure()
21890

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
226-
}
227-
}
228-
22991
fig.add_trace(
23092
go.Scatter(
23193
x=[1, 2, 3],
23294
y=[1, 3, 1]))
23395

234-
fig.show(config=config)
235-
```
236-
237-
##### Specifying Multiple Configuration Options Simultaneously!
238-
239-
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({
96+
fig.show(config={
24797
'scrollZoom': True,
24898
'displayModeBar': True,
24999
'editable': True
250100
})
251-
252-
fig.add_trace(
253-
go.Scatter(
254-
x=[1, 2, 3],
255-
y=[1, 3, 1]))
256-
257-
fig.show(config=config)
258101
```
259102

260103
##### Remove Modebar Buttons
261104

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:
263-
264-
-'2D': `zoom2d`, `pan2d`, `select2d`, `lasso2d`, `zoomIn2d`, `zoomOut2d`, `autoScale2d`, `resetScale2d`
265-
-'3D': `zoom3d`, `pan3d`, `rbitRotation`, `tableRotation`, `handleDrag3d`, resetCameraDefault3d, resetCameraLastSave3d, `hoverClosest3d`
266-
-'Cartesian': `hoverClosestCartesian`, `hoverCompareCartesian`
267-
-'Geo': `zoomInGeo`, `zoomOutGeo`, `resetGeo`, `hoverClosestGeo`
268-
-'Other': `hoverClosestGl2d`, `hoverClosestPie`, `toggleHover`, `resetViews`, `toImage: sendDataToCloud`, `toggleSpikelines`, `resetViewMapbox`
269-
270105
```python
271106
import plotly.graph_objects as go
272107

@@ -282,15 +117,13 @@ fig.show(config={
282117
})
283118
```
284119

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`).
120+
### Double-click Delay
121+
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).
288123

289124
```python
290125
import plotly.graph_objects as go
291126

292-
config = {'doubleClickDelay': 1000}
293-
294127
fig = go.Figure(go.Bar(
295128
y = [3, 5, 3, 2],
296129
x = ["2019-09-02", "2019-10-10", "2019-11-12", "2019-12-22"],
@@ -299,52 +132,7 @@ fig = go.Figure(go.Bar(
299132

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

302-
fig.show(config=config)
303-
```
304-
305-
#### Configuring Figures in Dash Apps
306-
307-
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.
308-
309-
```python
310-
import dash
311-
import dash_core_components as dcc
312-
import dash_html_components as html
313-
314-
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
315-
316-
app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
317-
318-
config = dict({
319-
'scrollZoom': True,
320-
'displayModeBar': True,
321-
'editable': True
322-
})
323-
324-
app.layout = html.Div(children=[
325-
html.H1(children='Hello Dash'),
326-
327-
html.Div(children='''
328-
Dash: A web application framework for Python.
329-
'''),
330-
331-
dcc.Graph(
332-
id='example-graph',
333-
figure={
334-
'data': [
335-
{'x': [1, 2, 3], 'y': [4, 1, 2], 'type': 'bar', 'name': 'SF'},
336-
{'x': [1, 2, 3], 'y': [2, 4, 5], 'type': 'bar', 'name': u'Montréal'},
337-
],
338-
'layout': {
339-
'title': 'Dash Data Visualization'
340-
}
341-
},
342-
config=config
343-
)
344-
])
345-
346-
# if __name__ == '__main__':
347-
# app.run_server(debug=True)
135+
fig.show(config = {'doubleClickDelay': 1000})
348136
```
349137

350138
#### Reference

0 commit comments

Comments
 (0)