Skip to content

Commit c8dc986

Browse files
Merge branch 'master' into add-pxlinks
2 parents b1e2003 + 3e7967c commit c8dc986

File tree

163 files changed

+9034
-3072
lines changed

Some content is hidden

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

163 files changed

+9034
-3072
lines changed

Diff for: .circleci/config.yml

+9
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,15 @@ jobs:
440440
git push --force [email protected]:plotly/plotly.py-docs.git master:built
441441
rm -rf .git
442442
cd ../..
443+
cd build/ipynb
444+
git init
445+
git config user.name plotlydocbot
446+
git config user.email [email protected]
447+
git add *
448+
git commit -m "build of https://github.com/plotly/plotly.py/commit/${CIRCLE_SHA1}"
449+
git push --force [email protected]:plotly/plotly.py-docs.git master:built_ipynb
450+
rm -rf .git
451+
cd ../..
443452
fi
444453
tar -zcf build/html.tgz build/html
445454
rm -rf build/html build/ipynb

Diff for: .gitattributes

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
plotly/_version.py export-subst
1+
packages/python/plotly/plotly/_version.py export-subst

Diff for: .github/pull_request_template.md

+1
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,6 @@ below :-).
3333
- [ ] For a new feature, I have added documentation examples in an existing or
3434
new tutorial notebook (please see the doc checklist as well).
3535
- [ ] I have added a CHANGELOG entry if fixing/changing/adding anything substantial.
36+
- [ ] For a new feature or a change in behaviour, I have updated the relevant docstrings in the code to describe the feature or behaviour (please see the doc checklist as well).
3637
3738
-->

Diff for: .gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ node_modules/
3131

3232
# virtual envs
3333
vv
34-
venv
34+
venv*
3535

3636
# dist files
3737
build
@@ -46,4 +46,5 @@ temp-plot.html
4646
doc/python/.ipynb_checkpoints
4747
doc/python/.mapbox_token
4848
doc/.ipynb_checkpoints
49+
tags
4950
doc/check-or-enforce-order.py

Diff for: CHANGELOG.md

+35
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,36 @@
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+
## [4.13.0] - UNRELEASED
6+
7+
### Added
8+
9+
- `go.Figure` now has a `set_subplots` method to set subplots on an already
10+
existing figure.
11+
- Added `Turbo` colorscale
12+
13+
14+
## [4.12.1] - UNRELEASED
15+
16+
17+
18+
## [4.12.0] - 2020-10-23
19+
20+
### Added
21+
22+
- For `add_trace`, `add_shape`, `add_annotation` and `add_layout_image`, the `row` and/or `col` argument now also accept the string `"all"`. `row="all"` adds the object to all the subplot rows and `col="all"` adds the object to all the subplot columns. ([#2840](https://github.com/plotly/plotly.py/pull/2840))
23+
- Shapes that reference the plot axes in one dimension and the data in another dimension can be added with the new `add_hline`, `add_vline`, `add_hrect`, `add_vrect` functions, which also support the `row="all"` and `col="all"` arguments. ([#2840](https://github.com/plotly/plotly.py/pull/2840))
24+
- The `add_trace`, `add_shape`, `add_annotation`, `add_layout_image`, `add_hline`, `add_vline`, `add_hrect`, `add_vrect` functions accept an argument `exclude_empty_subplots` which if `True`, only adds the object to subplots already containing traces or layout objects. This is useful in conjunction with the `row="all"` and `col="all"` arguments. ([#2840](https://github.com/plotly/plotly.py/pull/2840))
25+
- For all `go.Figure` functions accepting a selector argument (e.g., `select_traces`), this argument can now also be a function which is passed each relevant graph object (in the case of `select_traces`, it is passed every trace in the figure). For graph objects where this function returns true, the graph object is included in the selection. ([#2844](https://github.com/plotly/plotly.py/pull/2844))
26+
27+
### Added
28+
29+
- Better magic underscore error messages. For example, `some_fig.update_layout(geo_ltaxis_showgrid=True)` shows `Bad property path:\ngeo_ltaxis_showgrid\n ^` and lists the valid properties for `geo`.
30+
31+
### Updated
32+
33+
- Updated Plotly.js to version 1.57.1. See the [plotly.js CHANGELOG](https://github.com/plotly/plotly.js/blob/v1.57.1/CHANGELOG.md) for more information. These changes are reflected in the auto-generated `plotly.graph_objects` module.
34+
535
## [4.11.0] - 2020-10-01
636

737
### Updated
@@ -16,6 +46,11 @@ This project adheres to [Semantic Versioning](http://semver.org/).
1646

1747
### Updated
1848

49+
- The JSON serialization of plotly figures had been accelerated by handling
50+
differently figures with and without NaN and Inf values ([#2880](https://github.com/plotly/plotly.py/pull/2880)).
51+
52+
### Updated
53+
1954
- Updated Plotly.js to version 1.55.2. See the [plotly.js CHANGELOG](https://github.com/plotly/plotly.js/blob/v1.55.2/CHANGELOG.md) for more information. These changes are reflected in the auto-generated `plotly.graph_objects` module.
2055
- `px.imshow` has a new `binary_string` boolean argument, which passes the
2156
image data as a b64 binary string when True. Using binary strings allow for

Diff for: README.md

+10-6
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,13 @@
3131
</tr>
3232
</table>
3333

34+
## Data Science Workspaces
35+
36+
Our recommended IDE for Plotly’s Python graphing library is Dash Enterprise’s [Data Science Workspaces](https://plotly.com/dash/workspaces/), which has both Jupyter notebook and Python code file support.
37+
3438
## Quickstart
3539

36-
`pip install plotly==4.11.0`
40+
`pip install plotly==4.12.0`
3741

3842
Inside [Jupyter notebook](https://jupyter.org/install) (installable with `pip install "notebook>=5.3" "ipywidgets>=7.2"`):
3943

@@ -82,13 +86,13 @@ Built on top of [plotly.js](https://github.com/plotly/plotly.js), `plotly.py` is
8286
plotly.py may be installed using pip...
8387

8488
```
85-
pip install plotly==4.11.0
89+
pip install plotly==4.12.0
8690
```
8791

8892
or conda.
8993

9094
```
91-
conda install -c plotly plotly=4.11.0
95+
conda install -c plotly plotly=4.12.0
9296
```
9397

9498
### Jupyter Notebook Support
@@ -125,18 +129,18 @@ Then run the following commands to install the required JupyterLab extensions (n
125129

126130
```
127131
# Basic JupyterLab renderer support
128-
jupyter labextension install jupyterlab-plotly@4.11.0
132+
jupyter labextension install jupyterlab-plotly@4.12.0
129133
130134
# OPTIONAL: Jupyter widgets extension for FigureWidget support
131-
jupyter labextension install @jupyter-widgets/jupyterlab-manager plotlywidget@4.11.0
135+
jupyter labextension install @jupyter-widgets/jupyterlab-manager plotlywidget@4.12.0
132136
```
133137

134138
Please check out our [Troubleshooting guide](https://plotly.com/python/troubleshooting/) if you run into any problems with JupyterLab.
135139

136140
### Static Image Export
137141

138142
plotly.py supports [static image export](https://plotly.com/python/static-image-export/),
139-
using the either the [`kaleido`](https://github.com/plotly/Kaleido)
143+
using either the [`kaleido`](https://github.com/plotly/Kaleido)
140144
package (recommended, supported as of `plotly` version 4.9) or the [orca](https://github.com/plotly/orca)
141145
command line utility (legacy as of `plotly` version 4.9).
142146

Diff for: binder/requirements.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
jupytext
2-
plotly==4.11.0
2+
plotly==4.12.0
33
jupyter
44
notebook
55
pandas==1.0.3
@@ -18,3 +18,4 @@ cufflinks==0.17.3
1818
kaleido
1919
scikit-learn
2020
umap-learn
21+
wget

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 = "4.11.0"
31+
release = "4.12.0"
3232

3333

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

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

+50
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,56 @@ fig = go.Figure(data=[go.Bar(
287287
fig.show()
288288
```
289289

290+
Bar charts with custom widths can be used to make mekko charts (also known as marimekko charts, mosaic plots, or variwide charts).
291+
292+
```python
293+
import plotly.graph_objects as go
294+
import numpy as np
295+
296+
labels = ["apples","oranges","pears","bananas"]
297+
widths = np.array([10,20,20,50])
298+
299+
data = {
300+
"South": [50,80,60,70],
301+
"North": [50,20,40,30]
302+
}
303+
304+
fig = go.Figure()
305+
for key in data:
306+
fig.add_trace(go.Bar(
307+
name=key,
308+
y=data[key],
309+
x=np.cumsum(widths)-widths,
310+
width=widths,
311+
offset=0,
312+
customdata=np.transpose([labels, widths*data[key]]),
313+
texttemplate="%{y} x %{width} =<br>%{customdata[1]}",
314+
textposition="inside",
315+
textangle=0,
316+
textfont_color="white",
317+
hovertemplate="<br>".join([
318+
"label: %{customdata[0]}",
319+
"width: %{width}",
320+
"height: %{y}",
321+
"area: %{customdata[1]}",
322+
])
323+
))
324+
325+
fig.update_xaxes(
326+
tickvals=np.cumsum(widths)-widths/2,
327+
ticktext= ["%s<br>%d" % (l, w) for l, w in zip(labels, widths)]
328+
)
329+
330+
fig.update_xaxes(range=[0,100])
331+
fig.update_yaxes(range=[0,100])
332+
333+
fig.update_layout(
334+
title_text="Marimekko Chart",
335+
barmode="stack",
336+
uniformtext=dict(mode="hide", minsize=10),
337+
)
338+
```
339+
290340
### Customizing Individual Bar Base
291341

292342
```python

Diff for: doc/python/builtin-colorscales.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jupyter:
66
extension: .md
77
format_name: markdown
88
format_version: '1.2'
9-
jupytext_version: 1.3.1
9+
jupytext_version: 1.4.2
1010
kernelspec:
1111
display_name: Python 3
1212
language: python
@@ -20,7 +20,7 @@ jupyter:
2020
name: python
2121
nbconvert_exporter: python
2222
pygments_lexer: ipython3
23-
version: 3.6.8
23+
version: 3.7.7
2424
plotly:
2525
description: A reference for the built-in named continuous (sequential, diverging
2626
and cylclical) color scales in Plotly.
@@ -83,11 +83,11 @@ Here are all the built-in scales in the `plotly.colors.sequential` module:
8383
```python
8484
import plotly.express as px
8585

86-
fig = px.colors.sequential.swatches()
86+
fig = px.colors.sequential.swatches_continuous()
8787
fig.show()
8888
```
8989

90-
Note: `RdBu` was included in this module by mistake, even though it is a diverging color scale.
90+
Note: `RdBu` was included in the `sequential` module by mistake, even though it is a diverging color scale.
9191
It is intentionally left in for backwards-compatibility reasons.
9292

9393
### Built-In Diverging Color scales
@@ -102,7 +102,7 @@ Here are all the built-in scales in the `plotly.colors.diverging` module:
102102
```python
103103
import plotly.express as px
104104

105-
fig = px.colors.diverging.swatches().update_layout(margin_b=10)
105+
fig = px.colors.diverging.swatches_continuous()
106106
fig.show()
107107
```
108108

@@ -121,6 +121,6 @@ import plotly.express as px
121121
fig = px.colors.cyclical.swatches_cyclical()
122122
fig.show()
123123

124-
fig = px.colors.cyclical.swatches()
124+
fig = px.colors.cyclical.swatches_continuous()
125125
fig.show()
126-
```
126+
```

Diff for: doc/python/choropleth-maps.md

+21-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jupyter:
66
extension: .md
77
format_name: markdown
88
format_version: '1.2'
9-
jupytext_version: 1.3.1
9+
jupytext_version: 1.4.2
1010
kernelspec:
1111
display_name: Python 3
1212
language: python
@@ -20,7 +20,7 @@ jupyter:
2020
name: python
2121
nbconvert_exporter: python
2222
pygments_lexer: ipython3
23-
version: 3.6.8
23+
version: 3.7.7
2424
plotly:
2525
description: How to make choropleth maps in Python with Plotly.
2626
display_as: maps
@@ -164,7 +164,25 @@ fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
164164
fig.show()
165165
```
166166

167-
<!-- #region -->
167+
### Using GeoPandas Data Frames
168+
169+
`px.choropleth` accepts the `geometry` of a [GeoPandas](https://geopandas.org/) data frame as the input to `geojson` if the `geometry` contains polygons.
170+
171+
```python
172+
import plotly.express as px
173+
import geopandas as gpd
174+
175+
geo_df = gpd.read_file(gpd.datasets.get_path('nybb')).to_crs("EPSG:4326")
176+
177+
fig = px.choropleth(geo_df,
178+
geojson=geo_df.geometry,
179+
locations=geo_df.index,
180+
color='Shape_Leng',
181+
hover_name="BoroName")
182+
fig.update_geos(fitbounds="locations", visible=False)
183+
fig.show()
184+
```
185+
168186

169187
### Using Built-in Country and State Geometries
170188

@@ -179,7 +197,6 @@ Plotly comes with two built-in geometries which do not require an external GeoJS
179197
180198
To use the built-in countries geometry, provide `locations` as [three-letter ISO country codes](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3).
181199

182-
<!-- #endregion -->
183200

184201
```python
185202
import plotly.express as px

Diff for: doc/python/figure-structure.md

+15-2
Original file line numberDiff line numberDiff line change
@@ -95,18 +95,31 @@ The third of the three top-level attributes of a figure is `frames`, whose value
9595

9696
### The `config` Object
9797

98-
At [render-time](/python/renderers/), it is also possible to control certain figure behaviors which are not considered part of the figure proper i.e. the behaviour of the "modebar" and how the figure relates to mouse actions like scrolling etc. The object that contains these options is called the [`config`, and has its own documentation page](/python/configuration-options/). It is exposed in Python as the `config` keyword argument of the `.show()` method on `plotly.graph_objects.Figure` objects.
98+
At [render-time](/python/renderers/), it is also possible to control certain figure behaviors which are not considered part of the figure proper i.e. the behavior of the "modebar" and how the figure relates to mouse actions like scrolling etc. The object that contains these options is called the [`config`, and has its own documentation page](/python/configuration-options/). It is exposed in Python as the `config` keyword argument of the `.show()` method on `plotly.graph_objects.Figure` objects.
9999

100-
### Positioning With Paper or Container Coordinates
100+
### Positioning With Paper, Container Coordinates, or Axis Domain Coordinates
101101

102102
Various figure components configured within the layout of the figure support positioning attributes named `x` or `y`, whose values may be specified in "paper coordinates" (sometimes referred to as "plot fractions" or "normalized coordinates"). Examples include `layout.xaxis.domain` or `layout.legend.x` or `layout.annotation[].x`.
103103

104104
Positioning in paper coordinates is *not* done in absolute pixel terms, but rather in terms relative to a coordinate system defined with an origin `(0,0)` at `(layout.margin.l, layout.margin.b)` and a point `(1,1)` at `(layout.width-layout.margin.r, layout.height-layout.margin.t)` (note: `layout.margin` values are pixel values, as are `layout.width` and `layout.height`). Paper coordinate values less than 0 or greater than 1 are permitted, and refer to areas within the plot margins.
105105

106+
To position an object in "paper" coordinates, the corresponding axis reference
107+
is set to `"paper"`. For instance a shape's `xref` attribute would be set to
108+
`"paper"` so that the `x` value of the shape refers to its position in paper
109+
coordinates.
110+
106111
Note that the contents of the `layout.margin` attribute are by default computed based on the position and dimensions of certain items like the title or legend, and may be made dependent on the position and dimensions of tick labels as well when setting the `layout.xaxis.automargin` attribute to `True`. This has the effect of automatically increasing the margin values and therefore shrinking the physical area defined between the `(0,0)` and `(1,1)` points. Positioning certain items at paper coordinates less than 0 or greater than 1 will also trigger this behavior. The `layout.width` and `layout.height`, however, are taken as givens, so a figure will never grow or shrink based on its contents.
107112

108113
The figure title may be positioned using "container coordinates" which have `(0,0)` and `(1,1)` anchored at the bottom-left and top-right of the figure, respectively, and therefore are independent of the values of layout.margin.
109114

115+
Furthermore, shapes, annotations, and images can be placed relative to an axis's
116+
domain so that, for instance, an `x` value of `0.5` would place the object
117+
halfway along the x-axis, regardless of the domain as specified in the
118+
`layout.xaxis.domain` attribute. This behavior can be specified by adding
119+
`' domain'` to the axis reference in the axis referencing attribute of the object.
120+
For example, setting `yref = 'y2 domain'` for a shape will refer to the length
121+
and position of the axis named `y2`.
122+
110123
### 2D Cartesian Trace Types and Subplots
111124

112125
The most commonly-used kind of subplot is a [two-dimensional Cartesian subplot](/python/axes/). Traces compatible with these subplots support `xaxis` and `yaxis` attributes whose values must refer to corresponding objects in the layout portion of the figure. For example, if `xaxis="x"`, and `yaxis="y"` (which is the default) then this trace is drawn on the subplot at the intersection of the axes configured under `layout.xaxis` and `layout.yaxis`, but if `xaxis="x2"` and `yaxis="y3"` then the trace is drawn at the intersection of the axes configured under `layout.xaxis2` and `layout.yaxis3`. Note that attributes such as `layout.xaxis` and `layout.xaxis2` etc do not have to be explicitly defined, in which case default values will be inferred. Multiple traces of different types can be drawn on the same subplot.

Diff for: doc/python/getting-started.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ We also encourage you to join the [Plotly Community Forum](http://community.plot
5959
`plotly` may be installed using pip...
6060

6161
```
62-
$ pip install plotly==4.11.0
62+
$ pip install plotly==4.12.0
6363
```
6464

6565
or conda.
6666

6767
```
68-
$ conda install -c plotly plotly=4.11.0
68+
$ conda install -c plotly plotly=4.12.0
6969
```
7070

7171
This package contains everything you need to write figures to standalone HTML files.
@@ -144,10 +144,10 @@ Then run the following commands to install the required JupyterLab extensions (n
144144

145145
```
146146
# JupyterLab renderer support
147-
jupyter labextension install jupyterlab-plotly@4.11.0
147+
jupyter labextension install jupyterlab-plotly@4.12.0
148148
149149
# OPTIONAL: Jupyter widgets extension
150-
jupyter labextension install @jupyter-widgets/jupyterlab-manager plotlywidget@4.11.0
150+
jupyter labextension install @jupyter-widgets/jupyterlab-manager plotlywidget@4.12.0
151151
```
152152

153153
These packages contain everything you need to run JupyterLab...

0 commit comments

Comments
 (0)