Skip to content

Commit 612ceec

Browse files
committed
Merge with anywidget branch
2 parents 5eff0ca + 2dbdcea commit 612ceec

File tree

706 files changed

+8978
-41792
lines changed

Some content is hidden

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

706 files changed

+8978
-41792
lines changed

Diff for: .circleci/config.yml

+20-4
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ commands:
4646
. venv/bin/activate
4747
pip install --upgrade pip wheel
4848
pip install -r ./test_requirements/requirements_<<parameters.py>>_optional.txt
49-
python setup.py jsdeps
49+
cd js
50+
npm install
51+
npm run build
5052
- run:
5153
name: Install plotly-geo
5254
command: |
@@ -340,8 +342,9 @@ jobs:
340342
. venv/bin/activate
341343
pip install --upgrade pip wheel
342344
pip install -r ./test_requirements/requirements_38_core.txt black inflect
345+
pip install jupyterlab~=3.0
343346
- run:
344-
name: Update widget plotly.js version
347+
name: Update jupyterlab-plotly and jupyter widget plotly.js version
345348
command: |
346349
cd packages/python/plotly
347350
. venv/bin/activate
@@ -395,10 +398,20 @@ jobs:
395398
conda config --remove channels defaults
396399
conda config --add channels conda-forge
397400
conda create -n env --yes python=3.9 conda-build=3.28.4 conda-verify
398-
conda install -n env -c conda-forge nodejs=16
401+
conda install -n env -c conda-forge jupyterlab=3 nodejs=16
399402
conda init bash
400403
mkdir output
401404
405+
- run:
406+
name: initial NPM Build
407+
command: |
408+
eval "$(conda shell.bash hook)"
409+
conda activate env
410+
cd packages/javascript/jupyterlab-plotly
411+
npm ci
412+
npm run build:prod
413+
git status
414+
402415
- run:
403416
name: PyPI Build
404417
command: |
@@ -424,7 +437,10 @@ jobs:
424437
command: |
425438
eval "$(conda shell.bash hook)"
426439
conda activate env
427-
cd packages/python/plotly/js
440+
cd packages/javascript/jupyterlab-plotly
441+
npm pack
442+
mv jupyterlab-plotly*.tgz ../../../output
443+
cd ../../python/plotly/js
428444
npm run build
429445
mv ../bundle.js ../../../../output
430446

Diff for: CHANGELOG.md

+11
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
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+
### Removed
6+
- Drop deprecated `pointcloud` and `heatmapgl` traces from the API
7+
8+
### Updated
9+
10+
- Updated plotly.py to use base64 encoding of arrays in plotly JSON to improve performance.
11+
512
## [5.24.1] - 2024-09-12
613

714
### Updated
@@ -21,6 +28,10 @@ This project adheres to [Semantic Versioning](http://semver.org/).
2128

2229
- Fixed a bug in integer validation of arrays that threw an error when an array contained a mix of strings and integers.
2330

31+
- Fixed a bug in JupyterLab >= 4 and Jupyter Notebook >= 7 that caused latex to not render in plotly charts.
32+
33+
- Use modern [native ES6 import](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules) to load plotly.js bundle instead of requirejs which is [no longer under active development](https://github.com/requirejs/r.js/compare/2.3.6...2.3.7)
34+
2435
## [5.23.0] - 2024-07-23
2536

2637
### Updated

Diff for: contributing.md

+3-5
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,7 @@ There are many ways to contribute to plotly.py. To contribute effectively, it is
5757

5858
- tests are found in `packages/python/plotly/plotly/tests`. Different
5959
directories correspond to different test jobs (with different dependency sets)
60-
run in continuous integration. These jobs are configured in
61-
`packages/python/plotly/tox.ini`, which itself is used in the Circle CI
62-
configuration file `.circleci/config.yml`. More is explained about tests
60+
run in continuous integration. More is explained about tests
6361
in the following "Technical aspects" section.
6462

6563
- the **documentation** is part of this repository. Its structure and some
@@ -231,10 +229,10 @@ For dev branches, it is also possible to use `updateplotlyjsdev` in two configur
231229

232230
### CircleCI Release
233231

234-
If your devbranch is part of the official plotly.js repository, you can use
232+
If your devbranch is part of the official plotly.js repository, you can use
235233
```bash
236234
python setup.py updateplotlyjsdev --devrepo reponame --devbranch branchname
237-
```
235+
```
238236
to update to development versions of `plotly.js`. This will fetch the `plotly.js` in the CircleCI artifact of the branch `branchname` of the repo `reponame`. If `--devrepo` or `--devbranch` are omitted, `updateplotlyjsdev` defaults using `plotly/plotly.js` and `master` respectively.
239237

240238
### Local Repository

Diff for: doc/apidoc/plotly.graph_objects.rst

-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ Simple Traces
4343
Bar
4444
Pie
4545
Heatmap
46-
Heatmapgl
4746
Image
4847
Contour
4948
Table

Diff for: doc/python/3d-bubble-charts.md

+69-17
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ jupyter:
55
text_representation:
66
extension: .md
77
format_name: markdown
8-
format_version: '1.1'
9-
jupytext_version: 1.2.3
8+
format_version: '1.3'
9+
jupytext_version: 1.16.4
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.7.3
23+
version: 3.11.10
2424
plotly:
2525
description: How to make 3D Bubble Charts in Python with Plotly. Three examples
2626
of 3D Bubble Charts.
@@ -113,12 +113,38 @@ fig = go.Figure(data=go.Scatter3d(
113113
)
114114
))
115115

116-
fig.update_layout(width=800, height=800, title = 'Planets!',
117-
scene = dict(xaxis=dict(title='Distance from Sun', titlefont_color='white'),
118-
yaxis=dict(title='Density', titlefont_color='white'),
119-
zaxis=dict(title='Gravity', titlefont_color='white'),
120-
bgcolor = 'rgb(20, 24, 54)'
121-
))
116+
fig.update_layout(
117+
width=800,
118+
height=800,
119+
title="Planets!",
120+
scene=dict(
121+
xaxis=dict(
122+
title=dict(
123+
text="Distance from Sun",
124+
font=dict(
125+
color="white"
126+
)
127+
)
128+
),
129+
yaxis=dict(
130+
title=dict(
131+
text="Density",
132+
font=dict(
133+
color="white"
134+
)
135+
)
136+
),
137+
zaxis=dict(
138+
title=dict(
139+
text="Gravity",
140+
font=dict(
141+
color="white"
142+
)
143+
)
144+
),
145+
bgcolor="rgb(20, 24, 54)"
146+
)
147+
)
122148

123149
fig.show()
124150
```
@@ -154,16 +180,42 @@ fig = go.Figure(go.Scatter3d(
154180
)
155181
))
156182

157-
fig.update_layout(width=800, height=800, title = 'Planets!',
158-
scene = dict(xaxis=dict(title='Distance from Sun', titlefont_color='white'),
159-
yaxis=dict(title='Density', titlefont_color='white'),
160-
zaxis=dict(title='Gravity', titlefont_color='white'),
161-
bgcolor = 'rgb(20, 24, 54)'
162-
))
183+
fig.update_layout(
184+
width=800,
185+
height=800,
186+
title="Planets!",
187+
scene=dict(
188+
xaxis=dict(
189+
title=dict(
190+
text="Distance from Sun",
191+
font=dict(
192+
color="white"
193+
)
194+
)
195+
),
196+
yaxis=dict(
197+
title=dict(
198+
text="Density",
199+
font=dict(
200+
color="white"
201+
)
202+
)
203+
),
204+
zaxis=dict(
205+
title=dict(
206+
text="Gravity",
207+
font=dict(
208+
color="white"
209+
)
210+
)
211+
),
212+
bgcolor="rgb(20, 24, 54)"
213+
)
214+
)
163215

164216
fig.show()
165217
```
166218

167219
#### Reference
168220

169-
See https://plotly.com/python/reference/scatter3d/ and https://plotly.com/python/reference/scatter/#scatter-marker-sizeref <br>for more information and chart attribute options!
221+
See https://plotly.com/python/reference/scatter3d/ and https://plotly.com/python/reference/scatter/#scatter-marker-sizeref <br>for more information and chart attribute options!

Diff for: doc/python/animations.md

+22-21
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,7 @@ fig.show()
145145

146146
```python
147147
import plotly.graph_objects as go
148-
149148
import numpy as np
150-
151149
# Generate curve data
152150
t = np.linspace(-1, 1, 100)
153151
x = t + t ** 2
@@ -156,7 +154,7 @@ xm = np.min(x) - 1.5
156154
xM = np.max(x) + 1.5
157155
ym = np.min(y) - 1.5
158156
yM = np.max(y) + 1.5
159-
N = 50
157+
N = 25
160158
s = np.linspace(-1, 1, N)
161159
xx = s + s ** 2
162160
yy = s - s ** 2
@@ -167,26 +165,29 @@ fig = go.Figure(
167165
data=[go.Scatter(x=x, y=y,
168166
mode="lines",
169167
line=dict(width=2, color="blue")),
170-
go.Scatter(x=x, y=y,
171-
mode="lines",
172-
line=dict(width=2, color="blue"))],
173-
layout=go.Layout(
168+
go.Scatter(x=[xx[0]], y=[yy[0]],
169+
mode="markers",
170+
marker=dict(color="red", size=10))])
171+
fig.update_layout(width=600, height=450,
174172
xaxis=dict(range=[xm, xM], autorange=False, zeroline=False),
175173
yaxis=dict(range=[ym, yM], autorange=False, zeroline=False),
176-
title_text="Kinematic Generation of a Planar Curve", hovermode="closest",
177-
updatemenus=[dict(type="buttons",
178-
buttons=[dict(label="Play",
179-
method="animate",
180-
args=[None])])]),
181-
frames=[go.Frame(
182-
data=[go.Scatter(
183-
x=[xx[k]],
184-
y=[yy[k]],
185-
mode="markers",
186-
marker=dict(color="red", size=10))])
187-
188-
for k in range(N)]
189-
)
174+
title_text="Kinematic Generation of a Planar Curve", title_x=0.5,
175+
updatemenus = [dict(type = "buttons",
176+
buttons = [
177+
dict(
178+
args = [None, {"frame": {"duration": 10, "redraw": False},
179+
"fromcurrent": True, "transition": {"duration": 10}}],
180+
label = "Play",
181+
method = "animate",
182+
183+
)])])
184+
185+
fig.update(frames=[go.Frame(
186+
data=[go.Scatter(
187+
x=[xx[k]],
188+
y=[yy[k]])],
189+
traces=[1]) # fig.data[1] is updated by each frame
190+
for k in range(N)])
190191

191192
fig.show()
192193
```

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

+12-9
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jupyter:
3737

3838
[Plotly Express](/python/plotly-express/) is the easy-to-use, high-level interface to Plotly, which [operates on a variety of types of data](/python/px-arguments/) and produces [easy-to-style figures](/python/styling-plotly-express/).
3939

40-
With `px.bar`, **each row of the DataFrame is represented as a rectangular mark**. To aggregate multiple data points into the same rectangular mark, please refer to the [histogram documentation](/python/histograms).
40+
With `px.bar`, **each row of the DataFrame is represented as a rectangular mark**. To aggregate multiple data points into the same rectangular mark, please refer to the [histogram documentation](/python/histograms).
4141

4242
In the example below, there is only a single row of data per year, so a single bar is displayed per year.
4343

@@ -152,7 +152,7 @@ fig.show()
152152

153153
### Aggregating into Single Colored Bars
154154

155-
As noted above `px.bar()` will result in **one rectangle drawn per row of input**. This can sometimes result in a striped look as in the examples above. To combine these rectangles into one per color per position, you can use `px.histogram()`, which has [its own detailed documentation page](/python/histogram).
155+
As noted above `px.bar()` will result in **one rectangle drawn per row of input**. This can sometimes result in a striped look as in the examples above. To combine these rectangles into one per color per position, you can use `px.histogram()`, which has [its own detailed documentation page](/python/histogram).
156156

157157
> `px.bar` and `px.histogram` are designed to be nearly interchangeable in their call signatures, so as to be able to switch between aggregated and disaggregated bar representations.
158158
@@ -304,7 +304,7 @@ fig.update_layout(barmode='stack')
304304
fig.show()
305305
```
306306

307-
### Stacked Bar Chart From Aggregating a DataFrame
307+
### Stacked Bar Chart From Aggregating a DataFrame
308308

309309
Stacked bar charts are a powerful way to present results summarizing categories generated using the Pandas aggregate commands. `pandas.DataFrame.agg` produces a wide data set format incompatible with `px.bar`. Transposing and updating the indexes to achieve `px.bar` compatibility is a somewhat involved option. Here is one straightforward alternative, which presents the aggregated data as a stacked bar using plotly.graph_objects.
310310

@@ -326,19 +326,19 @@ df_summarized["percent of world population"]=100*df_summarized["pop"]/df_summari
326326
df_summarized["percent of world GDP"]=100*df_summarized["gdp"]/df_summarized["gdp"].sum()
327327

328328

329-
df = df_summarized[["continent",
329+
df = df_summarized[["continent",
330330
"percent of world population",
331331
"percent of world GDP",
332332
]]
333333

334334
# We now have a wide data frame, but it's in the opposite orientation from the one that px is designed to deal with.
335-
# Transposing it and rebuilding the indexes is an option, but iterating through the DF using graph objects is more succinct.
335+
# Transposing it and rebuilding the indexes is an option, but iterating through the DF using graph objects is more succinct.
336336

337337
fig=go.Figure()
338338
for category in df_summarized["continent"].values:
339339
fig.add_trace(go.Bar(
340340
x=df.columns[1:],
341-
# We need to get a pandas series that contains just the values to graph;
341+
# We need to get a pandas series that contains just the values to graph;
342342
# We do so by selecting the right row, selecting the right columns
343343
# and then transposing and using iloc to convert to a series
344344
# Here, we assume that the bar element category variable is in column 0
@@ -619,9 +619,12 @@ fig.update_layout(
619619
title='US Export of Plastic Scrap',
620620
xaxis_tickfont_size=14,
621621
yaxis=dict(
622-
title='USD (millions)',
623-
titlefont_size=16,
624-
tickfont_size=14,
622+
title=dict(
623+
text="USD (millions)",
624+
font=dict(
625+
size=16
626+
)
627+
),
625628
),
626629
legend=dict(
627630
x=0,

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

+3-9
Original file line numberDiff line numberDiff line change
@@ -233,16 +233,10 @@ import plotly.graph_objects as go
233233

234234
fig = go.Figure()
235235

236-
fig.add_trace(go.Box(y=[
237-
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ],
238-
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ],
239-
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ]
240-
], name="Precompiled Quartiles"))
241-
242-
fig.update_traces(q1=[ 1, 2, 3 ], median=[ 4, 5, 6 ],
236+
fig.add_trace(go.Box(q1=[ 1, 2, 3 ], median=[ 4, 5, 6 ],
243237
q3=[ 7, 8, 9 ], lowerfence=[-1, 0, 1],
244-
upperfence=[5, 6, 7], mean=[ 2.2, 2.8, 3.2 ],
245-
sd=[ 0.2, 0.4, 0.6 ], notchspan=[ 0.2, 0.4, 0.6 ] )
238+
upperfence=[7, 8, 9], mean=[ 2.2, 2.8, 3.2 ],
239+
sd=[ 0.2, 0.4, 0.6 ], notchspan=[ 0.2, 0.4, 0.6 ], name="Precompiled Quartiles"))
246240

247241
fig.show()
248242
```

Diff for: doc/python/carpet-contour.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,10 @@ fig.add_trace(go.Contourcarpet(
159159
colorbar = dict(
160160
y = 0,
161161
yanchor = "bottom",
162-
titleside = "right",
163162
len = 0.75,
164-
title = "Pressure coefficient, c<sub>p</sub>"
163+
title = dict(
164+
text="Pressure coefficient, c<sub>p</sub>",
165+
side="right")
165166
),
166167
contours = dict(
167168
start = -1,

0 commit comments

Comments
 (0)