Skip to content

Commit 39f872f

Browse files
'new in' and modebar info
1 parent 43c72ce commit 39f872f

8 files changed

+84
-49
lines changed

doc/python/bar-charts.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,16 @@ fig = px.bar(df, x="sex", y="total_bill",
133133
fig.show()
134134
```
135135

136+
*New in v5.0*
137+
138+
136139
Bar charts afford the use of [patterns (also known as hatching or texture)](/python/pattern-hatching-texture/) in addition to color:
137140

138141
```python
139142
import plotly.express as px
140143
df = px.data.medals_long()
141144

142-
fig = px.bar(df, x="medal", y="count", color="nation",
145+
fig = px.bar(df, x="medal", y="count", color="nation",
143146
pattern_shape="nation", pattern_shape_sequence=[".", "x", "+"])
144147
fig.show()
145148
```
@@ -347,8 +350,8 @@ for key in data:
347350
])
348351
))
349352

350-
fig.update_xaxes(
351-
tickvals=np.cumsum(widths)-widths/2,
353+
fig.update_xaxes(
354+
tickvals=np.cumsum(widths)-widths/2,
352355
ticktext= ["%s<br>%d" % (l, w) for l, w in zip(labels, widths)]
353356
)
354357

doc/python/configuration-options.md

+62-41
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,20 @@ fig.add_trace(
6363
fig.show(config=config)
6464
```
6565

66-
### Forcing The Modebar to Always Be Visible
66+
### Turning Off Responsiveness
6767

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.
68+
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.
6969

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.
70+
Try resizing your browser window to see this behavior in effect on this page.
71+
72+
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.
7173

7274
```python
7375
import plotly.graph_objects as go
7476

7577
fig = go.Figure()
7678

77-
config = {'displayModeBar': True}
79+
config = {'responsive': False}
7880

7981
fig.add_trace(
8082
go.Scatter(
@@ -84,18 +86,14 @@ fig.add_trace(
8486
fig.show(config=config)
8587
```
8688

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.
89+
### Making A Static Chart
9290

9391
```python
9492
import plotly.graph_objects as go
9593

9694
fig = go.Figure()
9795

98-
config = {'displayModeBar': False}
96+
config = {'staticPlot': True}
9997

10098
fig.add_trace(
10199
go.Scatter(
@@ -105,15 +103,18 @@ fig.add_trace(
105103
fig.show(config=config)
106104
```
107105

106+
### Forcing The Modebar to Always Be Visible
108107

109-
### Hiding the Plotly Logo on the Modebar
108+
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.
109+
110+
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.
110111

111112
```python
112113
import plotly.graph_objects as go
113114

114115
fig = go.Figure()
115116

116-
config = {'displaylogo': False}
117+
config = {'displayModeBar': True}
117118

118119
fig.add_trace(
119120
go.Scatter(
@@ -123,20 +124,18 @@ fig.add_trace(
123124
fig.show(config=config)
124125
```
125126

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.
127+
### Preventing the Modebar from Appearing
129128

130-
Try resizing your browser window to see this behavior in effect on this page.
129+
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.
131130

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.
131+
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.
133132

134133
```python
135134
import plotly.graph_objects as go
136135

137136
fig = go.Figure()
138137

139-
config = {'responsive': False}
138+
config = {'displayModeBar': False}
140139

141140
fig.add_trace(
142141
go.Scatter(
@@ -146,14 +145,15 @@ fig.add_trace(
146145
fig.show(config=config)
147146
```
148147

149-
### Making A Static Chart
148+
149+
### Hiding the Plotly Logo on the Modebar
150150

151151
```python
152152
import plotly.graph_objects as go
153153

154154
fig = go.Figure()
155155

156-
config = {'staticPlot': True}
156+
config = {'displaylogo': False}
157157

158158
fig.add_trace(
159159
go.Scatter(
@@ -163,7 +163,7 @@ fig.add_trace(
163163
fig.show(config=config)
164164
```
165165

166-
### Customizing Download Plot Button Options
166+
### Customizing Modebar "Download Plot" Button
167167

168168
The camera icon on the modebar causes a static version of the figure to be downloaded via the user's browser. The default behaviour is to download a PNG of size 700 by 450 pixels.
169169

@@ -202,38 +202,36 @@ fig = px.bar(x=[1, 2, 3], y=[1, 3, 1])
202202
fig.show(config=config)
203203
```
204204

205-
### Specifying Multiple Configuration Options Simultaneously
205+
### Removing Modebar Buttons
206206

207-
The dictionary that you use to specify configuration options for your figures can contain more than one configuration key/value pair.
207+
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:
208+
209+
- **High-level**: `zoom`, `pan`, `select`, `zoomIn`, `zoomOut`, `autoScale`, `resetScale`
210+
- **2D**: `zoom2d`, `pan2d`, `select2d`, `lasso2d`, `zoomIn2d`, `zoomOut2d`, `autoScale2d`, `resetScale2d`
211+
- **2D Shape Drawing**: `drawline`, `drawopenpath`, `drawclosedpath`, `drawcircle`, `drawrect`, `eraseshape`
212+
- **3D**: `zoom3d`, `pan3d`, `orbitRotation`, `tableRotation`, `handleDrag3d`, `resetCameraDefault3d`, `resetCameraLastSave3d`, `hoverClosest3d`
213+
- **Cartesian**: `hoverClosestCartesian`, `hoverCompareCartesian`
214+
- **Geo**: `zoomInGeo`, `zoomOutGeo`, `resetGeo`, `hoverClosestGeo`
215+
- **Other**: `hoverClosestGl2d`, `hoverClosestPie`, `toggleHover`, `resetViews`, `toImage`, `sendDataToCloud`, `toggleSpikelines`, `resetViewMapbox`
208216

209217
```python
210218
import plotly.graph_objects as go
211219

212220
fig = go.Figure()
213221

214-
config = dict({
215-
'scrollZoom': True,
216-
'displayModeBar': True,
217-
'editable': True
218-
})
219-
220222
fig.add_trace(
221223
go.Scatter(
222224
x=[1, 2, 3],
223225
y=[1, 3, 1]))
224226

225-
fig.show(config=config)
227+
fig.show(config={
228+
'modeBarButtonsToRemove': ['zoom', 'pan']
229+
})
226230
```
227231

228-
### Removing Modebar Buttons
232+
*New in v5.0*
229233

230-
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:
231-
232-
- **2D**: `zoom2d`, `pan2d`, `select2d`, `lasso2d`, `zoomIn2d`, `zoomOut2d`, `autoScale2d`, `resetScale2d`
233-
- **3D**: `zoom3d`, `pan3d`, `orbitRotation`, `tableRotation`, `handleDrag3d`, `resetCameraDefault3d`, `resetCameraLastSave3d`, `hoverClosest3d`
234-
- **Cartesian**: `hoverClosestCartesian`, `hoverCompareCartesian`
235-
- **Geo**: `zoomInGeo`, `zoomOutGeo`, `resetGeo`, `hoverClosestGeo`
236-
- **Other**: `hoverClosestGl2d`, `hoverClosestPie`, `toggleHover`, `resetViews`, `toImage: sendDataToCloud`, `toggleSpikelines`, `resetViewMapbox`
234+
The `layout.modebar.remove` attribute can be used instead of the approach used above:
237235

238236
```python
239237
import plotly.graph_objects as go
@@ -245,13 +243,13 @@ fig.add_trace(
245243
x=[1, 2, 3],
246244
y=[1, 3, 1]))
247245

248-
fig.show(config={
249-
'modeBarButtonsToRemove': ['toggleSpikelines','hoverCompareCartesian']
250-
})
246+
fig.update_layout(modebar_remove=['zoom', 'pan'])
251247
```
252248

253249
### Add optional shape-drawing buttons to modebar
254250

251+
*New in v4.7*
252+
255253
Some modebar buttons of Cartesian plots are optional and have to be added explicitly, using the `modeBarButtonsToAdd` config attribute. These buttons are used for drawing or erasing shapes. See [the tutorial on shapes and shape drawing](python/shapes#drawing-shapes-on-cartesian-plots) for more details.
256254

257255
```python
@@ -273,6 +271,29 @@ fig.show(config={'modeBarButtonsToAdd':['drawline',
273271
]})
274272
```
275273

274+
*New in v5.0*
275+
276+
The `layout.modebar.add` attribute can be used instead of the approach used above:
277+
278+
```python
279+
import plotly.graph_objects as go
280+
import plotly.express as px
281+
df = px.data.iris()
282+
fig = px.scatter(df, x='petal_width', y='sepal_length', color='species')
283+
fig.update_layout(
284+
dragmode='drawopenpath',
285+
newshape_line_color='cyan',
286+
title_text='Draw a path to separate versicolor and virginica',
287+
modebar_add=['drawline',
288+
'drawopenpath',
289+
'drawclosedpath',
290+
'drawcircle',
291+
'drawrect',
292+
'eraseshape'
293+
]
294+
)
295+
```
296+
276297
### Double-Click Delay
277298
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).
278299
This setting propagates to all on-subplot double clicks (except for `geo` and `mapbox`).

doc/python/histograms.md

+1
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ df = px.data.tips()
179179
fig = px.histogram(df, x="day", y="total_bill", category_orders=dict(day=["Thur", "Fri", "Sat", "Sun"]))
180180
fig.show()
181181
```
182+
*New in v5.0*
182183

183184
Histograms afford the use of [patterns (also known as hatching or texture)](/python/pattern-hatching-texture/) in addition to color:
184185

doc/python/hover-text-and-formatting.md

+2
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,8 @@ fig.show()
250250

251251
### Hover Templates with Mixtures of Period data
252252

253+
*New in v5.0*
254+
253255
When [displaying periodic data](https://plotly.com/python/time-series/#displaying-period-data) with mixed-sized periods (i.e. quarterly and monthly) in conjunction with `x` or `x unified` hovermodes and using `hovertemplate`, the `xhoverformat` attribute can be used to control how each period's X value is displayed, and the special `%{xother}` hover-template directive can be used to control how the X value is displayed for points that do not share the exact X coordinate with the point that is being hovered on. `%{xother}` will return an empty string when the X value is the one being hovered on, otherwise it will return `(%{x})`. The special `%{_xother}`, `%{xother_}` and `%{_xother_}` variations will display with spaces before, after or around the parentheses, respectively.
254256

255257
```python

doc/python/icicle-charts.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ jupyter:
3333
thumbnail: thumbnail/icicle.png
3434
---
3535

36+
*New in v5.0*
37+
3638
Icicle charts visualize hierarchical data using rectangular sectors that cascade from root to leaves in one of four directions: up, down, left, or right. Similar to [Sunburst charts](https://plotly.com/python/sunburst-charts/) and [Treemaps](https://plotly.com/python/treemaps/) charts, the hierarchy is defined by `labels` (`names` for `px.icicle`) and `parents` attributes. Click on one sector to zoom in/out, which also displays a pathbar on the top of your icicle. To zoom out, you can click the parent sector or click the pathbar as well.
3739

3840
### Basic Icicle Plot with plotly.express
@@ -96,7 +98,7 @@ When the argument of color corresponds to non-numerical data, discrete colors ar
9698
```python
9799
import plotly.express as px
98100
df = px.data.tips()
99-
fig = px.icicle(df, path=[px.Constant("all"), 'sex', 'day', 'time'],
101+
fig = px.icicle(df, path=[px.Constant("all"), 'sex', 'day', 'time'],
100102
values='total_bill', color='day')
101103
fig.update_layout(margin = dict(t=50, l=25, r=25, b=25))
102104
fig.show()
@@ -107,7 +109,7 @@ In the example below the color of **Saturday** and **Sunday** sectors is the sam
107109
```python
108110
import plotly.express as px
109111
df = px.data.tips()
110-
fig = px.icicle(df, path=[px.Constant("all"), 'sex', 'day', 'time'],
112+
fig = px.icicle(df, path=[px.Constant("all"), 'sex', 'day', 'time'],
111113
values='total_bill', color='time')
112114
fig.update_layout(margin = dict(t=50, l=25, r=25, b=25))
113115
fig.show()
@@ -120,7 +122,7 @@ For more information about discrete colors, see the [dedicated page](https://plo
120122
```python
121123
import plotly.express as px
122124
df = px.data.tips()
123-
fig = px.icicle(df, path=[px.Constant("all"), 'sex', 'day', 'time'],
125+
fig = px.icicle(df, path=[px.Constant("all"), 'sex', 'day', 'time'],
124126
values='total_bill', color='time',
125127
color_discrete_map={'(?)':'lightgrey', 'Lunch':'gold', 'Dinner':'darkblue'})
126128
fig.update_layout(margin = dict(t=50, l=25, r=25, b=25))
@@ -369,7 +371,7 @@ parents = ["", "container", "A1", "A2", "A3", "A4", "container", "B1"]
369371
fig = go.Figure(go.Icicle(
370372
labels = labels,
371373
parents = parents,
372-
marker_colors = ["pink", "royalblue", "lightgray", "purple",
374+
marker_colors = ["pink", "royalblue", "lightgray", "purple",
373375
"cyan", "lightgray", "lightblue", "lightgreen"]))
374376

375377
fig.update_layout(margin = dict(t=50, l=25, r=25, b=25))

doc/python/pattern-hatching-texture.md

+2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ jupyter:
3434
thumbnail: thumbnail/pattern.png
3535
---
3636

37+
*New in v5.0*
38+
3739
[Bar charts](/python/bar-charts/), [histograms](/python/histograms/) and [polar bar charts](/python/wind-rose-charts/) have large markers which support not only a fill color, but also an optional **pattern** (also known as "hatching" or "texture"). This can be used for a variety of reasons:
3840

3941
* to double-encode variables (i.e. using both color and pattern) to improve accessibility for visually-impaired end-users

doc/python/renderers.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,9 @@ It is important to note that `FigureWidget` does not use the renderers framework
253253

254254
## Performance
255255

256-
No matter the approach chosen to display a figure, [the figure data structure](https://plotly.com/python/figure-structure/) is first (automatically, internally) serialized into a JSON string before being transferred from the Python context to the browser (or [to an HTML file first](https://plotly.com/python/interactive-html-export/) or [to Kaleido for static image export](https://plotly.com/python/static-image-export/)).
256+
No matter the approach chosen to display a figure, [the figure data structure](https://plotly.com/python/figure-structure/) is first (automatically, internally) serialized into a JSON string before being transferred from the Python context to the browser (or [to an HTML file first](https://plotly.com/python/interactive-html-export/) or [to Kaleido for static image export](https://plotly.com/python/static-image-export/)).
257+
258+
*New in v5.0*
257259

258260
The default JSON serialization mechanism can be slow for figures with many data points or with large `numpy` arrays or data frames. **If [the `orjson` package](https://github.com/ijl/orjson) is installed**, `plotly` will use that instead of the built-in `json` package, which can lead to **5-10x** speedups for large figures.
259261

doc/python/time-series.md

+2
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,8 @@ fig.show()
205205

206206
### Hover Templates with Mixtures of Period data
207207

208+
*New in v5.0*
209+
208210
When displaying periodic data with mixed-sized periods (i.e. quarterly and monthly) in conjunction with [`x` or `x unified` hovermodes and using `hovertemplate`](https://plotly.com/python/hover-text-and-formatting/), the `xhoverformat` attribute can be used to control how each period's X value is displayed, and the special `%{xother}` hover-template directive can be used to control how the X value is displayed for points that do not share the exact X coordinate with the point that is being hovered on. `%{xother}` will return an empty string when the X value is the one being hovered on, otherwise it will return `(%{x})`. The special `%{_xother}`, `%{xother_}` and `%{_xother_}` variations will display with spaces before, after or around the parentheses, respectively.
209211

210212
```python

0 commit comments

Comments
 (0)