Skip to content

Commit e7b575e

Browse files
authored
Merge pull request #4135 from plotly/master
Update docs
2 parents 5cdbc04 + 743b524 commit e7b575e

File tree

324 files changed

+7285
-83
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

324 files changed

+7285
-83
lines changed

Diff for: CHANGELOG.md

+19
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,25 @@
22
All notable changes to this project will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

5+
## [5.14.0] - 2023-03-29
6+
7+
### Updated
8+
- Updated Plotly.js to from version 2.18.2 to version 2.20.0. See the [plotly.js CHANGELOG](https://github.com/plotly/plotly.js/blob/master/CHANGELOG.md#2200----2023-03-15) for more information. Notable changes include:
9+
- Add `title.automargin` to enable automatic top and bottom margining for both container and paper referenced titles [[#6428](https://github.com/plotly/plotly.js/pull/6428)],
10+
with thanks to [Gamma Technologies](https://www.gtisoft.com/) for sponsoring the related development.
11+
- Add `label` attribute to shapes [[#6454](https://github.com/plotly/plotly.js/pull/6454)], with thanks to the [Volkswagen](https://www.volkswagenag.com) Center of Excellence for Battery Systems for sponsoring development!
12+
- Add `labelalias` to various axes namely cartesian, gl3d, polar, smith, ternary, carpet,
13+
indicator and colorbar [[#6481](https://github.com/plotly/plotly.js/pull/6481)],
14+
this feature was anonymously sponsored: thank you to our sponsor!
15+
- Key errors no longer precalculated when performing updates on plots [[#4101](https://github.com/plotly/plotly.py/pull/4101)]
16+
17+
### Fixed
18+
- Fixed an issue with characters displaying incorrectly, by adding `charset="utf-8"` to scripts in `to_html` [[#4114](https://github.com/plotly/plotly.py/pull/4114)]
19+
- Added `packaging` to install requirements, fixing a `No module named 'packaging` error on Python 3.6 [[#4113](https://github.com/plotly/plotly.py/pull/4113)]
20+
21+
### Added
22+
- Added option to allow passing a column name as a `str` in `hover_data` and `custom_data` in `plotly.express` [[4083](https://github.com/plotly/plotly.py/pull/4083)]
23+
524
## [5.13.1] - 2023-02-24
625

726
### Updated

Diff for: README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
## Quickstart
3535

36-
`pip install plotly==5.13.1`
36+
`pip install plotly==5.14.0`
3737

3838
Inside [Jupyter](https://jupyter.org/install) (installable with `pip install "jupyterlab>=3" "ipywidgets>=7.6"`):
3939

@@ -78,13 +78,13 @@ Built on top of [plotly.js](https://github.com/plotly/plotly.js), `plotly.py` is
7878
plotly.py may be installed using pip...
7979

8080
```
81-
pip install plotly==5.13.1
81+
pip install plotly==5.14.0
8282
```
8383

8484
or conda.
8585

8686
```
87-
conda install -c plotly plotly=5.13.1
87+
conda install -c plotly plotly=5.14.0
8888
```
8989

9090
### JupyterLab Support
@@ -106,7 +106,7 @@ The instructions above apply to JupyterLab 3.x. **For JupyterLab 2 or earlier**,
106106

107107
```
108108
# JupyterLab 2.x renderer support
109-
jupyter labextension install jupyterlab-plotly@5.13.1 @jupyter-widgets/jupyterlab-manager
109+
jupyter labextension install jupyterlab-plotly@5.14.0 @jupyter-widgets/jupyterlab-manager
110110
```
111111

112112
Please check out our [Troubleshooting guide](https://plotly.com/python/troubleshooting/) if you run into any problems with JupyterLab.

Diff for: binder/requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
jupytext
2-
plotly==5.13.1
2+
plotly==5.14.0
33
jupyter
44
notebook
55
pandas==1.0.3

Diff for: doc/apidoc/conf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
# The short X.Y version
2929
version = ""
3030
# The full version, including alpha/beta/rc tags
31-
release = "5.13.1"
31+
release = "5.14.0"
3232

3333

3434
# -- General configuration ---------------------------------------------------

Diff for: doc/python/aggregations.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ import plotly.io as pio
144144

145145
import pandas as pd
146146

147-
df = pd.read_csv("https://plotly.com/~public.health/17.csv")
147+
df = pd.read_csv("https://raw.githubusercontent.com/plotly/datasets/master/US-shooting-incidents.csv")
148148

149149
data = [dict(
150150
x = df['date'],

Diff for: doc/python/axes.md

+19
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,25 @@ fig.update_yaxes(ticklabelposition="inside top", title=None)
154154
fig.show()
155155
```
156156

157+
#### Specifying Label Aliases
158+
159+
*New in 5.14*
160+
161+
With `labelalias`, you can specify replacement text for specific tick and hover labels. In this example, the dataset has the values of "Sat" and "Sun" in the day column. By setting `labelalias=dict(Sat="Saturday", Sun="Sunday")`, we swap these out for "Saturday" and "Sunday".
162+
163+
```python
164+
import plotly.express as px
165+
import pandas as pd
166+
167+
df = px.data.tips()
168+
df = df[df.day.isin(['Sat', 'Sun'])].groupby(by='day', as_index=False).sum(numeric_only=True)
169+
170+
fig = px.bar(df, x="day", y="total_bill")
171+
fig.update_xaxes(labelalias=dict(Sat="Saturday", Sun="Sunday"))
172+
173+
fig.show()
174+
```
175+
157176
##### Set axis title text with Graph Objects
158177

159178
Axis titles are set using the nested `title.text` property of the x or y axis. Here is an example of creating a new figure and using `update_xaxes` and `update_yaxes`, with magic underscore notation, to set the axis titles.

Diff for: doc/python/colorscales.md

+38-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ jupyter:
66
extension: .md
77
format_name: markdown
88
format_version: '1.3'
9-
jupytext_version: 1.14.1
9+
jupytext_version: 1.14.5
1010
kernelspec:
11-
display_name: Python 3
11+
display_name: Python 3 (ipykernel)
1212
language: python
1313
name: python3
1414
language_info:
@@ -20,7 +20,7 @@ jupyter:
2020
name: python
2121
nbconvert_exporter: python
2222
pygments_lexer: ipython3
23-
version: 3.8.8
23+
version: 3.10.9
2424
plotly:
2525
description: How to set, create and control continuous color scales and color
2626
bars in scatter, bar, map and heatmap figures.
@@ -298,6 +298,41 @@ fig.update_layout(coloraxis_colorbar=dict(
298298
fig.show()
299299
```
300300

301+
### Using Label Aliases on Colorbars
302+
303+
*New in 5.14*
304+
305+
Using `labelalias` you can replace some labels on the `colorbar` with alternative values. In this example, the `colorbar` has five `tickvals`. Using `labelalias`, instead of displaying all labels as the numbers in `tickvals`, we swap out three of the labels for text.
306+
307+
```python
308+
import plotly.graph_objects as go
309+
310+
import urllib
311+
import json
312+
313+
# Load heatmap data
314+
response = urllib.request.urlopen(
315+
"https://raw.githubusercontent.com/plotly/datasets/master/custom_heatmap_colorscale.json")
316+
dataset = json.load(response)
317+
318+
# Create and show figure
319+
fig = go.Figure()
320+
321+
fig.add_trace(go.Heatmap(
322+
z=dataset["z"],
323+
colorbar=dict(
324+
title="Surface Heat",
325+
titleside="top",
326+
tickmode="array",
327+
tickvals=[2, 25, 50, 75, 100],
328+
labelalias={100: "Hot", 50: "Mild", 2: "Cold"},
329+
ticks="outside"
330+
)
331+
))
332+
333+
fig.show()
334+
```
335+
301336
### Custom Discretized Heatmap Color scale with Graph Objects
302337

303338
```python

Diff for: doc/python/figure-labels.md

+23-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ jupyter:
66
extension: .md
77
format_name: markdown
88
format_version: '1.3'
9-
jupytext_version: 1.14.1
9+
jupytext_version: 1.14.5
1010
kernelspec:
11-
display_name: Python 3
11+
display_name: Python 3 (ipykernel)
1212
language: python
1313
name: python3
1414
language_info:
@@ -20,7 +20,7 @@ jupyter:
2020
name: python
2121
nbconvert_exporter: python
2222
pygments_lexer: ipython3
23-
version: 3.8.8
23+
version: 3.10.9
2424
plotly:
2525
description: How to set the global font, title, legend-entries, and axis-titles
2626
in python.
@@ -86,6 +86,26 @@ fig.update_xaxes(title_font_family="Arial")
8686
fig.show()
8787
```
8888

89+
### Set Automargin on the Plot Title
90+
91+
*New in 5.14*
92+
93+
Set `automargin=True` to allow the title to push the figure margins. With `yref` set to `paper`, `automargin=True` expands the margins to make the title visible, but doesn't push outside the container. With `yref` set to `container`, `automargin=True` expands the margins, but the title doesn't overlap with the plot area, tick labels, and axis titles.
94+
95+
96+
```python
97+
import plotly.express as px
98+
99+
df = px.data.gapminder().query("continent == 'Oceania'")
100+
fig = px.line(df, x="year", y="gdpPercap", color="country")
101+
102+
fig.update_layout(
103+
title=dict(text="GDP-per-capita", font=dict(size=50), automargin=True, yref='paper')
104+
)
105+
106+
fig.show()
107+
```
108+
89109
### Fonts and Labels in Dash
90110

91111
[Dash](https://plotly.com/dash/) is the best way to build analytical apps in Python using Plotly figures. To run the app below, run `pip install dash dash-daq`, click "Download" to get the code and run `python app.py`.

Diff for: doc/python/getting-started.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ We also encourage you to join the [Plotly Community Forum](http://community.plot
5858
`plotly` may be installed using `pip`:
5959

6060
```
61-
$ pip install plotly==5.13.1
61+
$ pip install plotly==5.14.0
6262
```
6363

6464
or `conda`:
6565

6666
```
67-
$ conda install -c plotly plotly=5.13.1
67+
$ conda install -c plotly plotly=5.14.0
6868
```
6969
This package contains everything you need to write figures to standalone HTML files.
7070

@@ -152,7 +152,7 @@ The instructions above apply to JupyterLab 3.x. **For JupyterLab 2 or earlier**,
152152

153153
```
154154
# JupyterLab 2.x renderer support
155-
jupyter labextension install jupyterlab-plotly@5.13.1 @jupyter-widgets/jupyterlab-manager
155+
jupyter labextension install jupyterlab-plotly@5.14.0 @jupyter-widgets/jupyterlab-manager
156156
```
157157

158158
Please check out our [Troubleshooting guide](/python/troubleshooting/) if you run into any problems with JupyterLab, particularly if you are using multiple python environments inside Jupyter.

Diff for: doc/python/horizontal-vertical-shapes.md

+41
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,47 @@ fig.add_vrect(x0="2018-09-24", x1="2018-12-18", row="all", col=1,
139139
fillcolor="green", opacity=0.25, line_width=0)
140140
fig.show()
141141
```
142+
#### Text Labels on Shapes
143+
144+
*New in 5.14*
145+
146+
[Text labels on shapes](/python/shapes/#addingtextlabelstoshapes), introduced in version 5.14, is now the recommended way to add text to shapes. The above examples using `add_hline`, `add_vrect`, `add_hrect`, and `add_vline` that add annotations can be rewritten to use `label`.
147+
148+
149+
```python
150+
import plotly.express as px
151+
152+
df = px.data.stocks(indexed=True)
153+
fig = px.line(df)
154+
fig.add_hline(
155+
y=1,
156+
line_dash="dot",
157+
label=dict(
158+
text="Jan 1 2018 Baseline",
159+
textposition="end",
160+
font=dict(size=20, color="blue"),
161+
yanchor="top",
162+
),
163+
)
164+
fig.add_vrect(
165+
x0="2018-09-24",
166+
x1="2018-12-18",
167+
label=dict(
168+
text="Decline",
169+
textposition="top center",
170+
font=dict(size=20, family="Times New Roman"),
171+
),
172+
fillcolor="green",
173+
opacity=0.25,
174+
line_width=0,
175+
)
176+
fig.show()
177+
178+
```
179+
180+
With [text labels on shapes](/python/shapes/#addingtextlabelstoshapes), you can also add text labels to shapes other than lines and rectangles, and the labels can be added automatically to shapes drawn by the user.
181+
182+
142183
### Reference
143184

144185
More details are available about [layout shapes](/python/shapes/) and [annotations](/python/text-and-annotations).

0 commit comments

Comments
 (0)