Skip to content

Commit 2d055a4

Browse files
authored
Merge pull request #4210 from plotly/update-plotly-js
Update plotly.js to 2.24.1 and add docs for new features
2 parents d1668b6 + 4367763 commit 2d055a4

File tree

1,341 files changed

+15136
-2198
lines changed

Some content is hidden

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

1,341 files changed

+15136
-2198
lines changed

Diff for: .circleci/config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ jobs:
432432
resource_class: xlarge
433433
docker:
434434
# specify the version you desire here
435-
# use `-browsers` prefix for selenium tests, e.g. `3.6.1-browsers`
435+
# use `-browsers` prefix for selenium tests, for example, `3.6.1-browsers`
436436
- image: cimg/python:3.7-browsers
437437

438438
steps:

Diff for: CHANGELOG.md

+14
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,20 @@ This project adheres to [Semantic Versioning](http://semver.org/).
44

55
## [UNRELEASED]
66

7+
8+
### Updated
9+
- Updated Plotly.js from version 2.20.0 to version 2.24.1. See the [plotly.js CHANGELOG](https://github.com/plotly/plotly.js/blob/master/CHANGELOG.md#2241----2023-06-07) for more information. Notable changes include:
10+
- Add pattern to pie, funnelarea, sunburst, icicle and treemap traces [[#6601](https://github.com/plotly/plotly.js/pull/6601), [#6619](https://github.com/plotly/plotly.js/pull/6619), [#6622](https://github.com/plotly/plotly.js/pull/6622), [#6626](https://github.com/plotly/plotly.js/pull/6626), [#6627](https://github.com/plotly/plotly.js/pull/6627), [#6628](https://github.com/plotly/plotly.js/pull/6628), [#6629](https://github.com/plotly/plotly.js/pull/6629)], with thanks to @thierryVergult for the contribution!
11+
- Add `texttemplate` to shape.label for parametric shapes i.e. line, rect and circle [[#6527](https://github.com/plotly/plotly.js/pull/6527)],
12+
with thanks to the [Volkswagen](https://www.volkswagenag.com) Center of Excellence for Battery Systems for sponsoring development!
13+
- Add strict option to custom bundle command [[#6557](https://github.com/plotly/plotly.js/pull/6557)],
14+
with thanks to @CallumNZ for the contribution!
15+
- Add `legend` references to traces and `legend2`, `legend3`, etc. to layout,
16+
also add `visible` to legend i.e. to allow positioning multiple legends on a graph [[#6535](https://github.com/plotly/plotly.js/pull/6535)],
17+
this feature was anonymously sponsored: thank you to our sponsor!
18+
- Add `legend.xref` and `legend.yref` to enable container-referenced positioning of legends [[#6589](https://github.com/plotly/plotly.js/pull/6589)], with thanks to [Gamma Technologies](https://www.gtisoft.com/) for sponsoring the related development.
19+
- Add `colorbar.xref` and `colorbar.yref` to enable container-referenced positioning of colorbars [[#6593](https://github.com/plotly/plotly.js/pull/6593)], with thanks to [Gamma Technologies](https://www.gtisoft.com/) for sponsoring the related development.
20+
721
### Fixed
822
- Fixed another compatibility issue with Pandas 2.0, just affecting `px.*(line_close=True)` [[#4190](https://github.com/plotly/plotly.py/pull/4190)]
923
- Empty pandas dataframe with facet row/column set no longer fails [[#4038](https://github.com/plotly/plotly.py/pull/4038)]

Diff for: doc/python/colorscales.md

+31-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jupyter:
2020
name: python
2121
nbconvert_exporter: python
2222
pygments_lexer: ipython3
23-
version: 3.10.9
23+
version: 3.10.11
2424
plotly:
2525
description: How to set, create and control continuous color scales and color
2626
bars in scatter, bar, map and heatmap figures.
@@ -632,6 +632,36 @@ fig = go.Figure(go.Heatmap(
632632
fig.show()
633633
```
634634

635+
### Positioning Colorbars
636+
637+
Colorbars can be positioned by specifying x and y coordinates. By default, the x and y values are "paper" coordinates, which refer to the plot area. You can also use coordinates based on the "container" by setting `xref="container"` or `yref="container"`. The following example uses a container reference for the x position.
638+
639+
See the positioning section of [the figure data structure page](/python/figure-structure/#positioning-with-paper-container-coordinates-or-axis-domain-coordinates) for more details on "paper" vs "container" coordinates.
640+
641+
```python
642+
import plotly.graph_objects as go
643+
644+
import urllib
645+
import json
646+
647+
# Load heatmap data
648+
response = urllib.request.urlopen(
649+
"https://raw.githubusercontent.com/plotly/datasets/master/custom_heatmap_colorscale.json")
650+
dataset = json.load(response)
651+
652+
# Create and show figure
653+
fig = go.Figure(go.Heatmap(
654+
z=dataset["z"],
655+
colorbar=dict(
656+
x=0.2,
657+
xref="container",
658+
title="Surface Heat"
659+
)
660+
))
661+
662+
fig.show()
663+
```
664+
635665
### Reference
636666

637667
See https://plotly.com/python/reference/ for more information and chart attribute options!

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

+25-3
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.2'
9-
jupytext_version: 1.3.0
8+
format_version: '1.3'
9+
jupytext_version: 1.14.6
1010
kernelspec:
11-
display_name: Python 3
11+
display_name: Python 3 (ipykernel)
1212
language: python
1313
name: python3
1414
plotly:
@@ -200,6 +200,28 @@ fig.update_layout(
200200
fig.show()
201201
```
202202

203+
### Pattern Fills
204+
205+
*New in 5.15*
206+
207+
Funnel area charts support [patterns](/python/pattern-hatching-texture/) (also known as hatching or texture) in addition to color. In this example, we add a pattern to the second stage of the funnel.
208+
209+
```python
210+
from plotly import graph_objects as go
211+
212+
colors = ["gold", "gold", "lightgreen", "lavender"]
213+
214+
fig = go.Figure(
215+
go.Funnelarea(
216+
labels=["Interview 1", "Interview 2", "Test", "Final Stage"],
217+
values=[100, 70, 40, 20],
218+
textfont_size=20,
219+
marker=dict(colors=colors, pattern=dict(shape=["", "/", "", ""])),
220+
)
221+
)
222+
fig.show()
223+
```
224+
203225
#### Reference
204226

205227
See [function reference for `px.(funnel)`](https://plotly.com/python-api-reference/generated/plotly.express.funnel) or https://plotly.com/python/reference/funnel/ and https://plotly.com/python/reference/funnelarea/ for more information and chart attribute options!

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

+28-4
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.2'
9-
jupytext_version: 1.4.2
8+
format_version: '1.3'
9+
jupytext_version: 1.14.6
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.7
23+
version: 3.10.11
2424
plotly:
2525
description: How to make Icicle Charts.
2626
display_as: basic
@@ -418,6 +418,30 @@ fig.update_layout(margin = dict(t=50, l=25, r=25, b=25))
418418
fig.show()
419419
```
420420

421+
### Pattern Fills
422+
423+
*New in 5.15*
424+
425+
Icicle charts support [patterns](/python/pattern-hatching-texture/) (also known as hatching or texture) in addition to color. In this example, we apply a pattern to all chart sections. We also configure the `size` and `solidity` of the pattern.
426+
427+
```python
428+
import plotly.graph_objects as go
429+
430+
fig = go.Figure(
431+
go.Icicle(
432+
labels=["Eve", "Cain", "Seth", "Enos", "Noam", "Abel", "Awan", "Enoch", "Azura"],
433+
parents=["", "Eve", "Eve", "Seth", "Seth", "Eve", "Eve", "Awan", "Eve"],
434+
values=[10, 14, 12, 10, 2, 6, 6, 4, 4],
435+
root_color="lightgrey",
436+
textfont_size=20,
437+
marker=dict(pattern=dict(shape="|", size=5, solidity=0.9)),
438+
)
439+
)
440+
441+
fig.update_layout(margin=dict(t=50, l=25, r=25, b=25))
442+
fig.show()
443+
```
444+
421445
### Set the Direction of Icicle charts
422446

423447
As mentioned above, Icicle charts can grow in one of four directions. Icicle charts have a `tiling` attribute and this has two attributes: `orientation` and `flip`. `orientation` takes either `h` (horiztonal) or `v` (vertical) and `flip` takes either `x` or `y`. You can use these two attributes in combination to create each of the four cardinal directions: left, right, top, bottom.

Diff for: doc/python/legend.md

+38-1
Original file line numberDiff line numberDiff line change
@@ -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 configure and style the legend in Plotly with Python.
2626
display_as: file_settings
@@ -638,6 +638,43 @@ fig.show()
638638

639639
```
640640

641+
### Positioning Legends
642+
643+
In the previous example, we position the second legend by specifying x and y values. By default, these values are based on the width and height of the plot area. It is also possible to specify values that reference the container width and height by setting "xref=container" and "yref="container" (the default values are "xref=paper" and "yref="paper"). When set to "container", the margin grows so the legend and plot don't overlap.
644+
645+
```python
646+
import plotly.graph_objects as go
647+
from plotly import data
648+
649+
df = data.gapminder()
650+
651+
df_germany = df.loc[(df.country.isin(["Germany"]))]
652+
df_france = df.loc[(df.country.isin(["France"]))]
653+
df_uk = df.loc[(df.country.isin(["United Kingdom"]))]
654+
655+
fig = go.Figure(
656+
data=[
657+
go.Scatter(x=df_germany.year, y=df_germany.gdpPercap, name="Germany"),
658+
go.Scatter(x=df_france.year, y=df_france.gdpPercap, name="France"),
659+
go.Scatter(x=df_uk.year, y=df_uk.gdpPercap, name="UK"),
660+
],
661+
layout=dict(
662+
title="GDP Per Capita",
663+
legend={
664+
"x": 0.9,
665+
"y": 0.9,
666+
"xref": "container",
667+
"yref": "container",
668+
"bgcolor": "Gold",
669+
"title": {"text": "By continent"},
670+
},
671+
),
672+
)
673+
674+
fig.show()
675+
676+
```
677+
641678
#### Reference
642679

643680
See https://plotly.com/python/reference/layout/#layout-legend for more information!

Diff for: doc/python/pattern-hatching-texture.md

+5-5
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.13.7
9+
jupytext_version: 1.14.6
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.9.7
23+
version: 3.10.11
2424
plotly:
2525
description: How to use patterns (also known as hatching or texture) with bar
2626
charts.
@@ -34,9 +34,9 @@ jupyter:
3434
thumbnail: thumbnail/pattern.png
3535
---
3636

37-
*New in v5.0*
37+
*New in 5.0, with support for pie, sunburst, icicle, funnelarea, and treemap charts in 5.15*
3838

39-
[Bar charts](/python/bar-charts/), [histograms](/python/histograms/), [polar bar charts](/python/wind-rose-charts/) and [area charts](/python/filled-area-plots/) have large markers or areas 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:
39+
[Bar charts](/python/bar-charts/), [histograms](/python/histograms/), [polar bar charts](/python/wind-rose-charts/), [area charts](/python/filled-area-plots/), [pie charts](/python/pie-charts), [sunburst charts](/python/sunburst-charts), [funnelarea charts](/python/funnel-charts), [icicle charts](/python/icicle-charts/), and [treemap charts](/python/treemaps), have large markers or areas 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:
4040

4141
* to double-encode variables (i.e. using both color and pattern) to improve accessibility for visually-impaired end-users
4242
* to encode an additional variable beyond just using color
@@ -79,7 +79,7 @@ In the charts above, the first value of the variable assigned `pattern_shape` ge
7979

8080
Here we use `pattern_shape_sequence` to replace the defaults and include a pattern-shape for the first variable:
8181

82-
```python tags=[]
82+
```python
8383
import plotly.express as px
8484
df = px.data.medals_long()
8585

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

+30-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.6
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 Pie Charts.
2626
display_as: basic
@@ -300,6 +300,33 @@ fig.update_layout(title_text='World GDP')
300300
fig.show()
301301
```
302302

303+
### Pattern Fills
304+
305+
*New in 5.15*
306+
307+
Pie charts support [patterns](/python/pattern-hatching-texture/) (also known as hatching or texture) in addition to color.
308+
309+
```python
310+
import plotly.graph_objects as go
311+
312+
labels = ["Oxygen", "Hydrogen", "Carbon_Dioxide", "Nitrogen"]
313+
values = [4500, 2500, 1053, 500]
314+
colors = ["gold", "mediumturquoise", "darkorange", "lightgreen"]
315+
316+
fig = go.Figure(
317+
data=[
318+
go.Pie(
319+
labels=labels,
320+
values=values,
321+
textfont_size=20,
322+
marker=dict(colors=colors, pattern=dict(shape=[".", "x", "+", "-"]))
323+
)
324+
]
325+
)
326+
327+
fig.show()
328+
```
329+
303330
### See Also: Sunburst charts
304331

305332
For multilevel pie charts representing hierarchical data, you can use the `Sunburst` chart. A simple example is given below, for more information see the [tutorial on Sunburst charts](/python/sunburst-charts/).

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

+34-4
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.2'
9-
jupytext_version: 1.4.2
8+
format_version: '1.3'
9+
jupytext_version: 1.14.6
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.7
23+
version: 3.10.11
2424
plotly:
2525
description: How to make Sunburst Charts.
2626
display_as: basic
@@ -300,6 +300,36 @@ fig.update_layout(uniformtext=dict(minsize=10, mode='hide'))
300300
fig.show()
301301
```
302302

303+
### Pattern Fills
304+
305+
*New in 5.15*
306+
307+
Sunburst charts support [patterns](/python/pattern-hatching-texture/) (also known as hatching or texture) in addition to color. In this example, we add a different pattern to each level of the hierarchy. We also specify the `solidity` of the pattern.
308+
309+
```python
310+
import plotly.graph_objects as go
311+
312+
fig = go.Figure(
313+
go.Sunburst(
314+
labels=["Eve", "Cain", "Seth", "Enos", "Noam", "Abel", "Awan", "Enoch", "Azura"],
315+
parents=["", "Eve", "Eve", "Seth", "Seth", "Eve", "Eve", "Awan", "Eve"],
316+
values=[65, 14, 12, 10, 2, 6, 6, 4, 4],
317+
branchvalues="total",
318+
textfont_size=16,
319+
marker=dict(
320+
pattern=dict(
321+
shape=["", "/", "/", ".", ".", "/", "/", ".", "/"], solidity=0.9
322+
)
323+
),
324+
)
325+
)
326+
327+
fig.update_layout(margin=dict(t=0, l=0, r=0, b=0))
328+
329+
fig.show()
330+
331+
```
332+
303333
### Sunburst chart with a continuous colorscale
304334

305335
The example below visualizes a breakdown of sales (corresponding to sector width) and call success rate (corresponding to sector color) by region, county and salesperson level. For example, when exploring the data you can see that although the East region is behaving poorly, the Tyler county is still above average -- however, its performance is reduced by the poor success rate of salesperson GT.

0 commit comments

Comments
 (0)