Skip to content

Update plotly.js to 2.24.1 and add docs for new features #4210

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 26 commits into from
Jun 7, 2023
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
392f9fc
update to plotly.js 2.23.0
LiamConnors May 15, 2023
f2447a4
Update CHANGELOG.md
LiamConnors May 15, 2023
942d9c1
Update legend.md
LiamConnors May 15, 2023
7d91cb7
Update colorscales.md
LiamConnors May 17, 2023
c90fd1d
Update Plotly.js version to 2.23.1
LiamConnors May 17, 2023
ff43b73
Update legend.md
LiamConnors May 17, 2023
ff0a454
Update CHANGELOG.md
LiamConnors May 17, 2023
6cb115c
Update doc/python/colorscales.md
LiamConnors May 17, 2023
e496849
Merge branch 'master' into update-plotly-js
LiamConnors Jun 3, 2023
f578cbc
Update Plotly.js version to 2.24.0
LiamConnors Jun 6, 2023
507b25f
Update pie-charts.md
LiamConnors Jun 6, 2023
f2473db
Update pattern-hatching-texture.md
LiamConnors Jun 6, 2023
04f682d
Update pattern-hatching-texture.md
LiamConnors Jun 6, 2023
96a9430
Merge branch 'master' into update-plotly-js
LiamConnors Jun 6, 2023
30a55a3
Update CHANGELOG.md
LiamConnors Jun 6, 2023
c26af7b
Update funnel-charts.md
LiamConnors Jun 6, 2023
c24c060
Update pattern-hatching-texture.md
LiamConnors Jun 6, 2023
253fa4e
Update sunburst-charts.md
LiamConnors Jun 6, 2023
7570bbf
Update treemaps.md
LiamConnors Jun 7, 2023
a97b2b4
Update icicle-charts.md
LiamConnors Jun 7, 2023
96ae271
formatting
LiamConnors Jun 7, 2023
d92676c
Update icicle-charts.md
LiamConnors Jun 7, 2023
a2a2bf3
Update CHANGELOG.md
LiamConnors Jun 7, 2023
16e663a
update plotly.js to 2.24.1
LiamConnors Jun 7, 2023
a28a1c4
Update config.yml
LiamConnors Jun 7, 2023
4367763
Update CHANGELOG.md
LiamConnors Jun 7, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ This project adheres to [Semantic Versioning](http://semver.org/).

## [UNRELEASED]

### Updated
- Updated Plotly.js from version 2.20.0 to version 2.23.1. See the [plotly.js CHANGELOG](https://github.com/plotly/plotly.js/blob/master/CHANGELOG.md#2231----2023-05-16) for more information. Notable changes include:
- Add `texttemplate` to shape.label for parametric shapes i.e. line, rect and circle [[#6527](https://github.com/plotly/plotly.js/pull/6527)],
with thanks to the [Volkswagen](https://www.volkswagenag.com) Center of Excellence for Battery Systems for sponsoring development!
- Add strict option to custom bundle command [[#6557](https://github.com/plotly/plotly.js/pull/6557)],
with thanks to @CallumNZ for the contribution!
- Add `legend` references to traces and `legend2`, `legend3`, etc. to layout,
also add `visible` to legend i.e. to allow positioning multiple legends on a graph [[#6535](https://github.com/plotly/plotly.js/pull/6535)],
this feature was anonymously sponsored: thank you to our sponsor!
- 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.
- 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.

### Fixed
- Fixed another compatibility issue with Pandas 2.0, just affecting `px.*(line_close=True)` [[#4190](https://github.com/plotly/plotly.py/pull/4190)]
- 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)]
Expand Down
32 changes: 31 additions & 1 deletion doc/python/colorscales.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jupyter:
name: python
nbconvert_exporter: python
pygments_lexer: ipython3
version: 3.10.9
version: 3.10.11
plotly:
description: How to set, create and control continuous color scales and color
bars in scatter, bar, map and heatmap figures.
Expand Down Expand Up @@ -632,6 +632,36 @@ fig = go.Figure(go.Heatmap(
fig.show()
```

### Positioning Colorbars

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.

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.

```python
import plotly.graph_objects as go

import urllib
import json

# Load heatmap data
response = urllib.request.urlopen(
"https://raw.githubusercontent.com/plotly/datasets/master/custom_heatmap_colorscale.json")
dataset = json.load(response)

# Create and show figure
fig = go.Figure(go.Heatmap(
z=dataset["z"],
colorbar=dict(
x=0.2,
xref="container",
title="Surface Heat"
)
))

fig.show()
```

### Reference

See https://plotly.com/python/reference/ for more information and chart attribute options!
39 changes: 38 additions & 1 deletion doc/python/legend.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jupyter:
name: python
nbconvert_exporter: python
pygments_lexer: ipython3
version: 3.8.8
version: 3.10.11
plotly:
description: How to configure and style the legend in Plotly with Python.
display_as: file_settings
Expand Down Expand Up @@ -638,6 +638,43 @@ fig.show()

```

### Positioning Legends

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.

```python
import plotly.graph_objects as go
from plotly import data

df = data.gapminder()

df_germany = df.loc[(df.country.isin(["Germany"]))]
df_france = df.loc[(df.country.isin(["France"]))]
df_uk = df.loc[(df.country.isin(["United Kingdom"]))]

fig = go.Figure(
data=[
go.Scatter(x=df_germany.year, y=df_germany.gdpPercap, name="Germany"),
go.Scatter(x=df_france.year, y=df_france.gdpPercap, name="France"),
go.Scatter(x=df_uk.year, y=df_uk.gdpPercap, name="UK"),
],
layout=dict(
title="GDP Per Capita",
legend={
"x": 0.9,
"y": 0.9,
"xref": "container",
"yref": "container",
"bgcolor": "Gold",
"title": {"text": "By continent"},
},
),
)

fig.show()

```

#### Reference

See https://plotly.com/python/reference/layout/#layout-legend for more information!
14 changes: 7 additions & 7 deletions packages/javascript/jupyterlab-plotly/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/javascript/jupyterlab-plotly/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"@lumino/messaging": "^1.2.3",
"@lumino/widgets": "^1.8.1",
"lodash": "^4.17.4",
"plotly.js": "^2.22.0"
"plotly.js": "^2.23.1"
},
"jupyterlab": {
"extension": "lib/jupyterlab-plugin",
Expand Down
Loading