Skip to content

Commit 1605982

Browse files
authored
Merge pull request #4542 from plotly/plotly-js-2-30-0
Update plotly js to 2.30.0
2 parents 6745ef1 + 8314429 commit 1605982

File tree

27 files changed

+684
-39
lines changed

27 files changed

+684
-39
lines changed

Diff for: .circleci/config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: 2.1
22

33
orbs:
4-
browser-tools: circleci/[email protected].6
4+
browser-tools: circleci/[email protected].8
55

66
commands:
77
test_core:

Diff for: CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
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+
## UNRELEASED
6+
7+
### Updated
8+
- Updated Plotly.js from version 2.29.1 to version 2.30.0. See the [plotly.js CHANGELOG](https://github.com/plotly/plotly.js/blob/master/CHANGELOG.md#2300----2024-03-06) for more information. These changes are reflected in the auto-generated `plotly.graph_objects` module. Notable changes include:
9+
- Add fill gradients for scatter traces [[#6905](https://github.com/plotly/plotly.js/pull/6905)], with thanks to @lumip for the contribution!
10+
- Add `indentation` to legend [[#6874](https://github.com/plotly/plotly.js/pull/6874)], with thanks to @my-tien for the contribution!
11+
12+
513
## [5.19.0] - 2024-02-15
614

715
### Updated

Diff for: doc/python/filled-area-plots.md

+42-6
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.16.1
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.11
2424
plotly:
2525
description: How to make filled area plots in Python with Plotly.
2626
display_as: basic
@@ -80,13 +80,11 @@ fig = px.area(df, x="medal", y="count", color="nation",
8080
fig.show()
8181
```
8282

83-
<!-- #region tags=[] -->
8483
### Filled area chart with plotly.graph_objects
8584

8685
#### Basic Overlaid Area Chart
87-
<!-- #endregion -->
8886

89-
```python tags=[]
87+
```python
9088
import plotly.graph_objects as go
9189

9290
fig = go.Figure()
@@ -131,6 +129,44 @@ fig.add_trace(go.Scatter(
131129
fig.show()
132130
```
133131

132+
#### Gradient Fill
133+
134+
*New in 5.20*
135+
136+
Scatter traces with a fill support a `fillgradient`, which is a `dict` of options that defines the gradient. Use `fillgradient.colorscale` to define the [colorscale](https://plotly.com/python/colorscales) for the gradient and choose a `type` to define the orientation of the gradient (`'horizontal'`, `'vertical'` or `'radial'`).
137+
138+
In the following example, we've defined a `horizontal` `fillgradient` with a colorscale of three colors.
139+
140+
```python
141+
import plotly.graph_objects as go
142+
143+
fig = go.Figure(
144+
[
145+
go.Scatter(
146+
x=[1, 2, 3, 4],
147+
y=[3, 4, 8, 3],
148+
fill=None,
149+
mode="lines",
150+
line_color="darkblue",
151+
),
152+
go.Scatter(
153+
x=[1, 2, 3, 4],
154+
y=[1, 6, 2, 6],
155+
fill="tonexty",
156+
mode="lines",
157+
line_color="darkblue",
158+
fillgradient=dict(
159+
type="horizontal",
160+
colorscale=[(0.0, "darkblue"), (0.5, "royalblue"), (1.0, "cyan")],
161+
),
162+
),
163+
]
164+
)
165+
166+
fig.show()
167+
168+
```
169+
134170
#### Stacked Area Chart
135171

136172
The `stackgroup` parameter is used to add the `y` values of the different traces in the same group. Traces in the same group fill up to the next trace of the group.

Diff for: doc/python/legend.md

+36-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.14.7
9+
jupytext_version: 1.16.1
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.4
23+
version: 3.10.11
2424
plotly:
2525
description: How to configure and style the legend in Plotly with Python.
2626
display_as: file_settings
@@ -546,6 +546,40 @@ fig.update_layout(title="Try Clicking on the Legend Items!")
546546
fig.show()
547547
```
548548

549+
#### Indent Legend Entries
550+
551+
*New in 5.20*
552+
553+
To indent legend entries, set `indenation` on `layout.legend` to a number of pixels. In the following example, we indent legend entries by 10 pixels.
554+
555+
```python
556+
import plotly.graph_objects as go
557+
from plotly import data
558+
559+
df = data.iris()
560+
561+
fig = go.Figure(
562+
[
563+
go.Scatter(
564+
x=df[df["species"] == species]["sepal_width"],
565+
y=df[df["species"] == species]["sepal_length"],
566+
mode="markers",
567+
name=species,
568+
)
569+
for species in df["species"].unique()
570+
],
571+
layout=dict(
572+
legend=dict(
573+
title="Species",
574+
indentation=10
575+
)
576+
),
577+
)
578+
579+
580+
fig.show()
581+
```
582+
549583
#### Group click toggle behavior
550584

551585
*New in v5.3*

Diff for: packages/javascript/jupyterlab-plotly/package-lock.json

+15-19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: packages/javascript/jupyterlab-plotly/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
"@lumino/messaging": "^1.2.3",
6666
"@lumino/widgets": "^1.8.1",
6767
"lodash": "^4.17.4",
68-
"plotly.js": "^2.29.1"
68+
"plotly.js": "^2.30.0"
6969
},
7070
"jupyterlab": {
7171
"extension": "lib/jupyterlab-plugin",

Diff for: packages/python/plotly/codegen/resources/plot-schema.json

+40-1
Original file line numberDiff line numberDiff line change
@@ -2848,6 +2848,13 @@
28482848
"valType": "number"
28492849
}
28502850
},
2851+
"indentation": {
2852+
"description": "Sets the indentation (in px) of the legend entries.",
2853+
"dflt": 0,
2854+
"editType": "legend",
2855+
"min": -15,
2856+
"valType": "number"
2857+
},
28512858
"itemclick": {
28522859
"description": "Determines the behavior on legend item click. *toggle* toggles the visibility of the item clicked on the graph. *toggleothers* makes the clicked item the sole visible item on the graph. *false* disables legend item click interactions.",
28532860
"dflt": "toggle",
@@ -45035,10 +45042,42 @@
4503545042
},
4503645043
"fillcolor": {
4503745044
"anim": true,
45038-
"description": "Sets the fill color. Defaults to a half-transparent variant of the line color, marker color, or marker line color, whichever is available.",
45045+
"description": "Sets the fill color. Defaults to a half-transparent variant of the line color, marker color, or marker line color, whichever is available. If fillgradient is specified, fillcolor is ignored except for setting the background color of the hover label, if any.",
4503945046
"editType": "style",
4504045047
"valType": "color"
4504145048
},
45049+
"fillgradient": {
45050+
"colorscale": {
45051+
"description": "Sets the fill gradient colors as a color scale. The color scale is interpreted as a gradient applied in the direction specified by *orientation*, from the lowest to the highest value of the scatter plot along that axis, or from the center to the most distant point from it, if orientation is *radial*.",
45052+
"editType": "style",
45053+
"valType": "colorscale"
45054+
},
45055+
"description": "Sets a fill gradient. If not specified, the fillcolor is used instead.",
45056+
"editType": "calc",
45057+
"role": "object",
45058+
"start": {
45059+
"description": "Sets the gradient start value. It is given as the absolute position on the axis determined by the orientiation. E.g., if orientation is *horizontal*, the gradient will be horizontal and start from the x-position given by start. If omitted, the gradient starts at the lowest value of the trace along the respective axis. Ignored if orientation is *radial*.",
45060+
"editType": "calc",
45061+
"valType": "number"
45062+
},
45063+
"stop": {
45064+
"description": "Sets the gradient end value. It is given as the absolute position on the axis determined by the orientiation. E.g., if orientation is *horizontal*, the gradient will be horizontal and end at the x-position given by end. If omitted, the gradient ends at the highest value of the trace along the respective axis. Ignored if orientation is *radial*.",
45065+
"editType": "calc",
45066+
"valType": "number"
45067+
},
45068+
"type": {
45069+
"description": "Sets the type/orientation of the color gradient for the fill. Defaults to *none*.",
45070+
"dflt": "none",
45071+
"editType": "calc",
45072+
"valType": "enumerated",
45073+
"values": [
45074+
"radial",
45075+
"horizontal",
45076+
"vertical",
45077+
"none"
45078+
]
45079+
}
45080+
},
4504245081
"fillpattern": {
4504345082
"bgcolor": {
4504445083
"arrayOk": true,

Diff for: packages/python/plotly/plotly/graph_objs/_figure.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -13179,6 +13179,7 @@ def add_scatter(
1317913179
error_y=None,
1318013180
fill=None,
1318113181
fillcolor=None,
13182+
fillgradient=None,
1318213183
fillpattern=None,
1318313184
groupnorm=None,
1318413185
hoverinfo=None,
@@ -13315,7 +13316,12 @@ def add_scatter(
1331513316
fillcolor
1331613317
Sets the fill color. Defaults to a half-transparent
1331713318
variant of the line color, marker color, or marker line
13318-
color, whichever is available.
13319+
color, whichever is available. If fillgradient is
13320+
specified, fillcolor is ignored except for setting the
13321+
background color of the hover label, if any.
13322+
fillgradient
13323+
Sets a fill gradient. If not specified, the fillcolor
13324+
is used instead.
1331913325
fillpattern
1332013326
Sets the pattern within the marker.
1332113327
groupnorm
@@ -13705,6 +13711,7 @@ def add_scatter(
1370513711
error_y=error_y,
1370613712
fill=fill,
1370713713
fillcolor=fillcolor,
13714+
fillgradient=fillgradient,
1370813715
fillpattern=fillpattern,
1370913716
groupnorm=groupnorm,
1371013717
hoverinfo=hoverinfo,

0 commit comments

Comments
 (0)