Skip to content

Commit a32a981

Browse files
authored
Merge branch 'master' into add-latest-docs-updates
2 parents b7a9c45 + 9b5ec6a commit a32a981

File tree

2,458 files changed

+89728
-5233
lines changed

Some content is hidden

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

2,458 files changed

+89728
-5233
lines changed

Diff for: .circleci/config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ jobs:
448448
docker:
449449
# specify the version you desire here
450450
# use `-browsers` prefix for selenium tests, for example, `3.9-browsers`
451-
- image: cimg/python:3.9-browsers
451+
- image: cimg/python:3.10-browsers
452452

453453
steps:
454454
- add_ssh_keys:

Diff for: CHANGELOG.md

+18
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,24 @@
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.23.0] - TBD
6+
7+
### Updated
8+
- Updated Plotly.js from version 2.32.0 to version 2.34.0. See the [plotly.js CHANGELOG](https://github.com/plotly/plotly.js/blob/master/CHANGELOG.md#2340----2024-07-18) for more information. These changes are reflected in the auto-generated `plotly.graph_objects` module. Notable changes include:
9+
- Add `subtitle` attribute to `layout.title` to enable adding subtitles to plots [[#7012](https://github.com/plotly/plotly.js/pull/7012)]
10+
- Introduce "u" and "s" pseudo html tags to add partial underline and strike-through styles to SVG text elements [[#7043](https://github.com/plotly/plotly.js/pull/7043)]
11+
- Add geometric mean functionality and 'geometric mean ascending' + 'geometric mean descending' to `category_order` on cartesian axes [[#6223](https://github.com/plotly/plotly.js/pull/6223)],
12+
with thanks to @acxz and @prabhathc for the contribution!
13+
- Add axis property `ticklabelindex` for drawing the label for each minor tick n positions away from a major tick,
14+
with thanks to @my-tien for the contribution! [[#7036](https://github.com/plotly/plotly.js/pull/7036)]
15+
- Add property `ticklabelstandoff` and `ticklabelshift` to cartesian axes to adjust positioning of tick labels,
16+
with thanks to @my-tien for the contribution! [[#7006](https://github.com/plotly/plotly.js/pull/7006)]
17+
- Add `x0shift`, `x1shift`, `y0shift`, `y1shift` to shapes to add control over positioning of shape vertices on (multi-)category axes,
18+
with thanks to @my-tien for the contribution! [[#7005](https://github.com/plotly/plotly.js/pull/7005)]
19+
- Specify Python version 3.8-3.11 for development virtual environments and pin `pytest` at version 8.1.1 to match.
20+
- Update `IntegerValidator` to handle `extras` option to allow supporting additional keyword values. For example, 'bold' and 'normal' as well as integers as used in font weights [#4612].
21+
22+
523
## [5.22.0] - 2024-05-01
624

725
### Updated

Diff for: README.md

+7
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@
3131
</tr>
3232
</table>
3333

34+
<div align="center">
35+
<a href="https://dash.plotly.com/project-maintenance">
36+
<img src="https://dash.plotly.com/assets/images/maintained-by-plotly.png" width="400px" alt="Maintained by Plotly">
37+
</a>
38+
</div>
39+
40+
3441
## Quickstart
3542

3643
`pip install plotly==5.22.0`

Diff for: binder/requirements.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ jupytext
22
plotly==5.22.0
33
jupyter
44
notebook
5-
pandas==1.2.0
6-
statsmodels==0.12.1
5+
pandas==2.2.2
6+
statsmodels==0.14.2
77
scipy
8-
patsy==0.5.1
8+
patsy==0.5.6
99
numpy
1010
plotly-geo
1111
psutil

Diff for: contributing.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,16 @@ learn and become confident about git, like http://try.github.io/.
125125

126126
### Create a virtual environment for plotly development
127127

128-
You can use either [conda][conda-env] or [virtualenv][virtualenv] to create a virtual environment for plotly development, e.g.
128+
You can use either [conda][conda-env] or [virtualenv][virtualenv] to create a virtual environment for plotly development, e.g.:
129129

130130
```bash
131-
conda create -n plotly-dev python
131+
conda create -n plotly-dev python=3.11
132132
conda activate plotly-dev
133133
```
134134

135+
As of May 2024 our dependencies have been tested against Python versions 3.8 to 3.11.
136+
We will support Python 3.12 and higher versions soon.
137+
135138
[conda-env]: https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#creating-an-environment-with-commands
136139
[virtualenv]: http://docs.python-guide.org/en/latest/dev/virtualenvs/
137140

Diff for: doc/python/3d-volume.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ np.random.seed(0)
8686
l = 30
8787
X, Y, Z = np.mgrid[:l, :l, :l]
8888
vol = np.zeros((l, l, l))
89-
pts = (l * np.random.rand(3, 15)).astype(np.int)
89+
pts = (l * np.random.rand(3, 15)).astype(int)
9090
vol[tuple(indices for indices in pts)] = 1
9191
from scipy import ndimage
9292
vol = ndimage.gaussian_filter(vol, 4)

Diff for: doc/python/axes.md

+72-12
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jupyter:
66
extension: .md
77
format_name: markdown
88
format_version: '1.3'
9-
jupytext_version: 1.16.1
9+
jupytext_version: 1.16.3
1010
kernelspec:
1111
display_name: Python 3 (ipykernel)
1212
language: python
@@ -20,7 +20,7 @@ jupyter:
2020
name: python
2121
nbconvert_exporter: python
2222
pygments_lexer: ipython3
23-
version: 3.10.11
23+
version: 3.10.14
2424
plotly:
2525
description: How to adjust axes properties in Python - axes titles, styling and
2626
coloring axes and grid lines, ticks, tick labels and more.
@@ -367,7 +367,7 @@ fig.show()
367367

368368
*New in 5.19*
369369

370-
If `tickangle` is not explicitly set, its default value is `auto`, meaning if the label needs to be rotated to avoid labels overlapping, it will rotate by either 30 or 90 degrees. Using `autotickangles`, you can also specify a list of angles for `tickangle` to use. If `tickangle` is `auto` and you provide a list of angles to `autotickangles`, the label angle will be set to the first value in the list that prevents overlap.
370+
If `tickangle` is not explicitly set, its default value is `auto`, meaning if the label needs to be rotated to avoid labels overlapping, it will rotate by either 30 or 90 degrees. Using `autotickangles`, you can also specify a list of angles for `tickangle` to use. If `tickangle` is `auto` and you provide a list of angles to `autotickangles`, the label angle will be set to the first value in the list that prevents overlap.
371371

372372
```python
373373
import plotly.express as px
@@ -390,14 +390,18 @@ Here is an example.
390390
import plotly.graph_objects as go
391391
import pandas as pd
392392

393-
# Load and filter Apple stock data for 2016
394393
apple_df = pd.read_csv(
395-
"https://raw.githubusercontent.com/plotly/datasets/master/finance-charts-apple.csv",
396-
parse_dates=["Date"],
397-
index_col="Date"
394+
"https://raw.githubusercontent.com/plotly/datasets/master/finance-charts-apple.csv"
398395
)
399396

400-
apple_df_2016 = apple_df["2016"]
397+
# Convert 'Date' column to datetime format
398+
apple_df['Date'] = pd.to_datetime(apple_df['Date'])
399+
400+
# Set 'Date' column as index
401+
apple_df.set_index('Date', inplace=True)
402+
403+
# Filter for 2016
404+
apple_df_2016 = apple_df.loc['2016']
401405

402406
# Create figure and add line
403407
fig = go.Figure()
@@ -444,6 +448,62 @@ fig.update_yaxes(minor_ticks="inside")
444448
fig.show()
445449
```
446450

451+
#### Adjust Tick Label Positions
452+
453+
*New in 5.23*
454+
455+
You can adjust tick label positions by moving them a number of pixels away from the axis using `ticklabelstandoff` or along the axis using `ticklabelshift`.
456+
457+
In this example, `ticklabelshift=25` shifts the labels 25 pixels to the right along the x-axis. By providing a negative value, we could move the labels 25 pixels to the left, (`ticklabelshift=-25`).
458+
459+
Here, `ticklabelstandoff=15` moves the labels further 15 pixels away from the x-axis. A negative value here would move them close to the axis.
460+
461+
```python
462+
import plotly.express as px
463+
464+
df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/finance-charts-apple.csv')
465+
466+
fig = px.line(df, x='Date', y='AAPL.High')
467+
468+
fig.update_layout(
469+
xaxis=dict(
470+
ticks='outside',
471+
ticklen=10,
472+
ticklabelshift=25,
473+
ticklabelstandoff=15
474+
)
475+
)
476+
477+
fig.show()
478+
```
479+
480+
#### Use Minor Tick for Label
481+
482+
*New in 5.23*
483+
484+
On date or linear axes, use `ticklabelindex` to draw a label for a minor tick instead of a major tick.
485+
486+
To draw the label for the minor tick before each major tick, set `ticklabelindex` -1, like in the following example.
487+
488+
```python
489+
import plotly.express as px
490+
491+
df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/finance-charts-apple.csv')
492+
493+
fig = px.line(df, x='Date', y='AAPL.High')
494+
495+
fig.update_layout(
496+
xaxis=dict(
497+
minor=dict(ticks='outside'),
498+
ticks='outside',
499+
ticklen=10,
500+
ticklabelindex=-1
501+
)
502+
)
503+
504+
fig.show()
505+
```
506+
447507
### Axis lines: grid and zerolines
448508

449509
##### Toggling Axis grid lines
@@ -599,7 +659,7 @@ fig.show()
599659

600660
*New in 5.17*
601661

602-
You can also set just a lower or upper bound manually and have autorange applied to the other bound by setting it to `None`. In the following example, we set a an upper bound of 4.5 on the x axes, while specifying `None` for the lower bound, meaning it will use autorange. On the y axes, we set the lower bound, and use `None` for the upper bound, meaning that uses autorange.
662+
You can also set just a lower or upper bound manually and have autorange applied to the other bound by setting it to `None`. In the following example, we set a an upper bound of 4.5 on the x axes, while specifying `None` for the lower bound, meaning it will use autorange. On the y axes, we set the lower bound, and use `None` for the upper bound, meaning that uses autorange.
603663

604664
```python
605665
import plotly.express as px
@@ -857,7 +917,7 @@ fig.show()
857917

858918
#### <code>nonnegative</code>, <code>tozero</code>, and <code>normal</code> Rangemode
859919

860-
When you don't specify a range, autorange is used. It's also used for bounds set to `None` when providing a `range`.
920+
When you don't specify a range, autorange is used. It's also used for bounds set to `None` when providing a `range`.
861921

862922
The axis auto-range calculation logic can be configured using the `rangemode` axis parameter.
863923

@@ -898,7 +958,7 @@ fig.update_xaxes(autorangeoptions=dict(maxallowed=5))
898958
fig.show()
899959
```
900960

901-
##### Clip Minimum and Maximum
961+
##### Clip Minimum and Maximum
902962

903963
You can also clip an axis range at a specific maximum or minimum value with `autorangeoptions.clipmax` and `autorangeoptions.clipmin`.
904964

@@ -916,7 +976,7 @@ fig.show()
916976

917977
##### Specify Values to be Included
918978

919-
Use `autorangeoptions.include` to specify a value that should always be included within the calculated autorange. In this example, we specify that for the autorange calculated on the x-axis, 5 should be included.
979+
Use `autorangeoptions.include` to specify a value that should always be included within the calculated autorange. In this example, we specify that for the autorange calculated on the x-axis, 5 should be included.
920980

921981
```python
922982
import plotly.express as px

Diff for: doc/python/box-plots.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -458,12 +458,12 @@ x_data = ['Carmelo Anthony', 'Dwyane Wade',
458458

459459
N = 50
460460

461-
y0 = (10 * np.random.randn(N) + 30).astype(np.int)
462-
y1 = (13 * np.random.randn(N) + 38).astype(np.int)
463-
y2 = (11 * np.random.randn(N) + 33).astype(np.int)
464-
y3 = (9 * np.random.randn(N) + 36).astype(np.int)
465-
y4 = (15 * np.random.randn(N) + 31).astype(np.int)
466-
y5 = (12 * np.random.randn(N) + 40).astype(np.int)
461+
y0 = (10 * np.random.randn(N) + 30).astype(int)
462+
y1 = (13 * np.random.randn(N) + 38).astype(int)
463+
y2 = (11 * np.random.randn(N) + 33).astype(int)
464+
y3 = (9 * np.random.randn(N) + 36).astype(int)
465+
y4 = (15 * np.random.randn(N) + 31).astype(int)
466+
y5 = (12 * np.random.randn(N) + 40).astype(int)
467467

468468
y_data = [y0, y1, y2, y3, y4, y5]
469469

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

+41-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jupyter:
66
extension: .md
77
format_name: markdown
88
format_version: '1.3'
9-
jupytext_version: 1.16.1
9+
jupytext_version: 1.16.3
1010
kernelspec:
1111
display_name: Python 3 (ipykernel)
1212
language: python
@@ -20,7 +20,7 @@ jupyter:
2020
name: python
2121
nbconvert_exporter: python
2222
pygments_lexer: ipython3
23-
version: 3.10.11
23+
version: 3.10.14
2424
plotly:
2525
description: How to set the global font, title, legend-entries, and axis-titles
2626
in python.
@@ -236,5 +236,44 @@ fig.update_layout(
236236
fig.show()
237237
```
238238

239+
### Adding a Plot Subtitle
240+
241+
*New in 5.23*
242+
243+
Add a subtitle to a plot with `layout.title.subtitle`. In the following example, we set the subtitle's `text`, and configure the `font` `color` and `size`. By default, if you don't set a font size for the subtitle, it will be `0.7` of the `title` font size.
244+
245+
```python
246+
import plotly.graph_objects as go
247+
from plotly import data
248+
249+
df = data.gapminder().query("continent == 'Europe' and (year == 1952 or year == 2002)")
250+
251+
df_pivot = df.pivot(index="country", columns="year", values="lifeExp")
252+
253+
fig = go.Figure(
254+
[
255+
go.Bar(
256+
x=df_pivot.index, y=df_pivot[1952], name="1952", marker_color="IndianRed"
257+
),
258+
go.Bar(
259+
x=df_pivot.index, y=df_pivot[2002], name="2002", marker_color="LightSalmon"
260+
),
261+
],
262+
layout=dict(
263+
title=dict(
264+
text="Life Expectancy",
265+
subtitle=dict(
266+
text="Life expectancy by European country in 1952 and in 2002",
267+
font=dict(color="gray", size=13),
268+
),
269+
)
270+
),
271+
)
272+
273+
274+
fig.show()
275+
276+
```
277+
239278
#### Reference
240279
See https://plotly.com/python/reference/layout/ for more information!

Diff for: doc/python/icicle-charts.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ def build_hierarchical_dataframe(df, levels, value_column, color_columns=None):
305305
Levels are given starting from the bottom to the top of the hierarchy,
306306
ie the last level corresponds to the root.
307307
"""
308-
df_all_trees = pd.DataFrame(columns=['id', 'parent', 'value', 'color'])
308+
df_list = []
309309
for i, level in enumerate(levels):
310310
df_tree = pd.DataFrame(columns=['id', 'parent', 'value', 'color'])
311311
dfg = df.groupby(levels[i:]).sum()
@@ -317,11 +317,12 @@ def build_hierarchical_dataframe(df, levels, value_column, color_columns=None):
317317
df_tree['parent'] = 'total'
318318
df_tree['value'] = dfg[value_column]
319319
df_tree['color'] = dfg[color_columns[0]] / dfg[color_columns[1]]
320-
df_all_trees = df_all_trees.append(df_tree, ignore_index=True)
320+
df_list.append(df_tree)
321321
total = pd.Series(dict(id='total', parent='',
322322
value=df[value_column].sum(),
323-
color=df[color_columns[0]].sum() / df[color_columns[1]].sum()))
324-
df_all_trees = df_all_trees.append(total, ignore_index=True)
323+
color=df[color_columns[0]].sum() / df[color_columns[1]].sum()), name=0)
324+
df_list.append(total)
325+
df_all_trees = pd.concat(df_list, ignore_index=True)
325326
return df_all_trees
326327

327328

Diff for: doc/python/mixed-subplots.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ df = pd.read_csv(
5555
)
5656

5757
# frequency of Country
58-
freq = df
59-
freq = freq.Country.value_counts().reset_index().rename(columns={"index": "x"})
58+
freq = df['Country'].value_counts().reset_index()
59+
freq.columns = ['x', 'Country']
6060

6161
# read in 3d volcano surface data
6262
df_v = pd.read_csv("https://raw.githubusercontent.com/plotly/datasets/master/volcano.csv")

Diff for: doc/python/ml-regression.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ from sklearn.linear_model import LinearRegression
120120
from sklearn.model_selection import train_test_split
121121

122122
df = px.data.tips()
123-
X = df.total_bill[:, None]
123+
X = df.total_bill.to_numpy()[:, None]
124124
X_train, X_test, y_train, y_test = train_test_split(X, df.tip, random_state=0)
125125

126126
model = LinearRegression()
@@ -129,7 +129,6 @@ model.fit(X_train, y_train)
129129
x_range = np.linspace(X.min(), X.max(), 100)
130130
y_range = model.predict(x_range.reshape(-1, 1))
131131

132-
133132
fig = go.Figure([
134133
go.Scatter(x=X_train.squeeze(), y=y_train, name='train', mode='markers'),
135134
go.Scatter(x=X_test.squeeze(), y=y_test, name='test', mode='markers'),

0 commit comments

Comments
 (0)