Skip to content

Commit b4a3565

Browse files
authored
Merge pull request #4239 from plotly/master
Merge master back in to doc-prod to deploy updated docs
2 parents 19d02b1 + 981ace8 commit b4a3565

File tree

646 files changed

+21379
-3887
lines changed

Some content is hidden

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

646 files changed

+21379
-3887
lines changed

Diff for: .circleci/config.yml

+158-59
Large diffs are not rendered by default.

Diff for: .gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,6 @@ doc/check-or-enforce-order.py
5252
packages/javascript/jupyterlab-plotly/lib/
5353
packages/python/plotly/jupyterlab_plotly/labextension/
5454
packages/python/plotly/jupyterlab_plotly/nbextension/index.js*
55+
56+
test/percy/*.html
57+
test/percy/pandas2/*.html

Diff for: CHANGELOG.md

+29-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,34 @@
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.15.0] - 2023-06-08
6+
7+
### Updated
8+
- 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:
9+
- 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!
10+
- Add `texttemplate` to shape.label for parametric shapes i.e. line, rect and circle [[#6527](https://github.com/plotly/plotly.js/pull/6527)],
11+
with thanks to the [Volkswagen](https://www.volkswagenag.com) Center of Excellence for Battery Systems for sponsoring development!
12+
- Add strict option to custom bundle command [[#6557](https://github.com/plotly/plotly.js/pull/6557)],
13+
with thanks to @CallumNZ for the contribution!
14+
- Add `legend` references to traces and `legend2`, `legend3`, etc. to layout,
15+
also add `visible` to legend i.e. to allow positioning multiple legends on a graph [[#6535](https://github.com/plotly/plotly.js/pull/6535)],
16+
this feature was anonymously sponsored: thank you to our sponsor!
17+
- 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.
18+
- 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.
19+
- `px` methods now accept data-frame-like objects that support a `to_pandas()` method, such as polars, cudf, vaex etc
20+
21+
### Fixed
22+
- Fixed another compatibility issue with Pandas 2.0, just affecting `px.*(line_close=True)` [[#4190](https://github.com/plotly/plotly.py/pull/4190)]
23+
- Empty pandas dataframe with facet row/column set no longer fails [[#4038](https://github.com/plotly/plotly.py/pull/4038)]
24+
- Added some rounding to the `make_subplots` function to handle situations where the user-input specs cause the domain to exceed 1 by small amounts [[#4153](https://github.com/plotly/plotly.py/pull/4153)]
25+
- Sanitize JSON output to prevent an XSS vector when graphs are inserted directly into HTML [[#4196](https://github.com/plotly/plotly.py/pull/4196)]
26+
- Fixed issue with shapes and annotations plotting on the wrong y axis when supplied with a specific axis in the `yref` parameter [[#4177](https://github.com/plotly/plotly.py/pull/4177)]
27+
- Remove `use_2to3` setuptools arg, which is invalid in the latest Python and setuptools versions [[#4206](https://github.com/plotly/plotly.py/pull/4206)]
28+
- Fix [#4066](https://github.com/plotly/plotly.py/issues/4066) JupyterLab v4 giving tiny default graph height [[#4227](https://github.com/plotly/plotly.py/pull/4227)]
29+
- Fixed issue with `colors.n_colors` where generated RGB color values were not being constrained to stay between 0 and 255 [[#4110](https://github.com/plotly/plotly.py/pull/4110)]
30+
- Fix streamline figure factory with recent versions of Numpy
31+
- Fix issue with shapes and annotations not drawing on correct axis [[#4177](https://github.com/plotly/plotly.py/pull/4177)]
32+
533
## [5.14.1] - 2023-04-05
634

735
### Fixed
@@ -10,7 +38,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
1038
## [5.14.0] - 2023-03-29
1139

1240
### Updated
13-
- 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:
41+
- Updated Plotly.js 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:
1442
- 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)],
1543
with thanks to [Gamma Technologies](https://www.gtisoft.com/) for sponsoring the related development.
1644
- 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!

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.14.1`
36+
`pip install plotly==5.15.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.14.1
81+
pip install plotly==5.15.0
8282
```
8383

8484
or conda.
8585

8686
```
87-
conda install -c plotly plotly=5.14.1
87+
conda install -c plotly plotly=5.15.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.14.1 @jupyter-widgets/jupyterlab-manager
109+
jupyter labextension install jupyterlab-plotly@5.15.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.14.1
2+
plotly==5.15.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.14.1"
31+
release = "5.15.0"
3232

3333

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

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/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.14.1
61+
$ pip install plotly==5.15.0
6262
```
6363

6464
or `conda`:
6565

6666
```
67-
$ conda install -c plotly plotly=5.14.1
67+
$ conda install -c plotly plotly=5.15.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.14.1 @jupyter-widgets/jupyterlab-manager
155+
jupyter labextension install jupyterlab-plotly@5.15.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/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

+103-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.1
9+
jupytext_version: 1.14.5
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.8.0
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
@@ -574,6 +574,107 @@ fig.update_layout(width=600, title_text='Exploration of a vector field using sev
574574
fig.show()
575575
```
576576

577+
### Adding Multiple Legends
578+
579+
*New in 5.15*
580+
581+
By default, all traces appear on one legend. To have multiple legends, specify an alternative legend for a trace using the `legend` property. For a second legend, set `legend="legend2"`. Specify more legends with `legend="legend3"`, `legend="legend4"` and so on.
582+
583+
In this example, the last two scatter traces display on the second legend, "legend2". On the figure's layout, we then position and style this legend to display on the right of the graph below the first legend.
584+
585+
586+
```python
587+
import plotly.graph_objects as go
588+
from plotly import data
589+
590+
df = data.gapminder()
591+
592+
df_germany = df.loc[(df.country.isin(["Germany"]))]
593+
df_france = df.loc[(df.country.isin(["France"]))]
594+
df_uk = df.loc[(df.country.isin(["United Kingdom"]))]
595+
596+
597+
df_averages_europe = (
598+
df.loc[(df.continent.isin(["Europe"]))].groupby(by="year").mean(numeric_only=True)
599+
)
600+
df_averages_americas = (
601+
df.loc[(df.continent.isin(["Americas"]))].groupby(by="year").mean(numeric_only=True)
602+
)
603+
604+
605+
fig = go.Figure(
606+
data=[
607+
go.Scatter(x=df_germany.year, y=df_germany.gdpPercap, name="Germany"),
608+
go.Scatter(x=df_france.year, y=df_france.gdpPercap, name="France"),
609+
go.Scatter(x=df_uk.year, y=df_uk.gdpPercap, name="UK"),
610+
go.Scatter(
611+
x=df_averages_europe.index,
612+
y=df_averages_europe.gdpPercap,
613+
name="Europe",
614+
legend="legend2",
615+
),
616+
go.Scatter(
617+
x=df_averages_americas.index,
618+
y=df_averages_americas.gdpPercap,
619+
name="Americas",
620+
legend="legend2",
621+
),
622+
],
623+
layout=dict(
624+
title="GDP Per Capita",
625+
legend={"title": "By country", "bgcolor": "Orange",},
626+
legend2={
627+
"x": 1.155,
628+
"y": 0.55,
629+
"xanchor": "right",
630+
"yanchor": "middle",
631+
"bgcolor": "Gold",
632+
"title": {"text": "By continent"},
633+
},
634+
),
635+
)
636+
637+
fig.show()
638+
639+
```
640+
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+
577678
#### Reference
578679

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

0 commit comments

Comments
 (0)