Skip to content

Commit 644215c

Browse files
authored
Merge branch 'plotly:master' into 3984-facets-empty-dataset
2 parents e6dd4b4 + 1e4bb3f commit 644215c

File tree

1,171 files changed

+5673
-1634
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,171 files changed

+5673
-1634
lines changed

Diff for: CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
66

77
### Fixed
88
- Fixed another compatibility issue with Pandas 2.0, just affecting `px.*(line_close=True)` [[#4190](https://github.com/plotly/plotly.py/pull/4190)]
9+
- 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 https://github.com/plotly/plotly.py/pull/4153
910

1011
## [5.14.1] - 2023-04-05
1112

@@ -15,7 +16,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
1516
## [5.14.0] - 2023-03-29
1617

1718
### Updated
18-
- 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:
19+
- 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:
1920
- 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)],
2021
with thanks to [Gamma Technologies](https://www.gtisoft.com/) for sponsoring the related development.
2122
- 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: doc/python/legend.md

+66-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.8.8
2424
plotly:
2525
description: How to configure and style the legend in Plotly with Python.
2626
display_as: file_settings
@@ -574,6 +574,70 @@ 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+
577641
#### Reference
578642

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

Diff for: doc/python/shapes.md

+87-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.8.8
2424
plotly:
2525
description: How to make SVG shapes in python. Examples of lines, circle, rectangle,
2626
and path.
@@ -913,5 +913,91 @@ fig.add_shape(
913913
fig.show()
914914
```
915915

916+
#### Variables in Shape Label Text
917+
918+
*New in 5.15*
919+
920+
Use `texttemplate` to add text with variables to shapes. `texttemplate` uses d3 number and date formatting and supports raw variables, which use the raw data from the shape definition, and some calculated variables. Add a variable with "%{variable}".
921+
922+
This example adds the raw variables `x0` and `y0` to a rectangle and shows the calculated variables `height`, `slope`, and `width` on three other shapes.
923+
924+
For a complete list of available variables, see the [Shape Reference Docs](https://plotly.com/python/reference/layout/shapes/).
925+
926+
927+
```python
928+
import plotly.graph_objects as go
929+
930+
fig = go.Figure()
931+
932+
fig.add_shape(
933+
type="rect",
934+
fillcolor="MediumSlateBlue",
935+
x0=-0.5,
936+
y0=-0.5,
937+
x1=1,
938+
y1=1,
939+
label=dict(
940+
texttemplate="x0 is %{x0:.3f}, y0 is %{y0:.3f}", font=dict(color="DarkOrange")
941+
),
942+
)
943+
944+
fig.add_shape(
945+
type="rect",
946+
fillcolor="LightGreen",
947+
x0=1,
948+
y0=1.75,
949+
x1=2.25,
950+
y1=3,
951+
label=dict(texttemplate="Height: %{height:.3f}", font=dict(color="DarkOrange")),
952+
)
953+
fig.add_shape(
954+
type="line",
955+
x0=3,
956+
y0=0.5,
957+
x1=5,
958+
y1=0.8,
959+
line_width=3,
960+
label=dict(texttemplate="Slope: %{slope:.3f}", font=dict(size=20)),
961+
)
962+
fig.add_shape(
963+
type="rect",
964+
fillcolor="Lavender",
965+
x0=2.5,
966+
y0=2.5,
967+
x1=5,
968+
y1=3.5,
969+
label=dict(
970+
texttemplate="Width: %{width:.3f}",
971+
font=dict(family="Courier New, monospace", size=20),
972+
),
973+
)
974+
975+
fig.show()
976+
977+
```
978+
979+
#### Variables in Shape Label Text for New Shapes
980+
981+
*New in 5.15*
982+
983+
Use `texttemplate` to add text with variables to new shapes drawn on the graph. This example figure is configured to allow the user to draw lines and automatically labels each line with its slope. Select **Draw line** in the modebar to try it out.
984+
985+
```python
986+
import plotly.graph_objects as go
987+
988+
fig = go.Figure(
989+
layout=go.Layout(newshape=dict(label=dict(texttemplate="Slope: %{slope:.3f}")))
990+
)
991+
992+
fig.show(
993+
config={
994+
"modeBarButtonsToAdd": [
995+
"drawline",
996+
]
997+
}
998+
)
999+
1000+
```
1001+
9161002
### Reference
9171003
See https://plotly.com/python/reference/layout/shapes/ for more information and chart attribute options!

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

+7-7
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.20.0"
68+
"plotly.js": "^2.22.0"
6969
},
7070
"jupyterlab": {
7171
"extension": "lib/jupyterlab-plugin",

0 commit comments

Comments
 (0)