Skip to content

Commit fa7a4dc

Browse files
Merge branch 'master' into more_pandas
2 parents 9f62088 + c7282c7 commit fa7a4dc

File tree

85 files changed

+1147
-704
lines changed

Some content is hidden

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

85 files changed

+1147
-704
lines changed

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,4 @@ temp-plot.html
4646
doc/python/.ipynb_checkpoints
4747
doc/python/.mapbox_token
4848
doc/.ipynb_checkpoints
49+
doc/check-or-enforce-order.py

Diff for: CHANGELOG.md

+18-1
Original file line numberDiff line numberDiff line change
@@ -2,17 +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+
56
## [4.9.0] - unreleased
67

78
### Updated
89

910
- Added all cartesian-2d Plotly Express functions, plus `imshow` to Pandas backend with `kind` option
11+
- `plotly.express.imshow` now uses data frame index and columns names and values to populate axis parameters by default ([#2539](https://github.com/plotly/plotly.py/pull/2539))
12+
13+
14+
## [4.8.2] - 2020-06-26
15+
16+
### Updated
17+
18+
- Updated Plotly.js to version 1.54.5. See the [plotly.js CHANGELOG](https://github.com/plotly/plotly.js/blob/v1.54.5/CHANGELOG.md) for more information.
19+
- `add_traces()` now accepts bare `int`-like values for `rows`/`cols` as well as lists thereof ([#2546](https://github.com/plotly/plotly.py/pull/2546)), with thanks to [@MCBoarder289](https://github.com/MCBoarder289) for the contribution!
1020

11-
## [4.8.2] - unreleased
1221

1322
### Fixed
1423

24+
- `row`/`col` now accept `int`-like values, not strictly `int` values ([#2451](https://github.com/plotly/plotly.py/pull/2451)), with thanks to [@MCBoarder289](https://github.com/MCBoarder289) for the contribution!
1525
- Fixed special cases with `px.sunburst` and `px.treemap` with `path` input ([#2524](https://github.com/plotly/plotly.py/pull/2524))
26+
- Fixed bug in `hover_data` argument of `px` functions, when the column name is changed with labels and `hover_data` is a dictionary setting up a specific format for the hover data ([#2544](https://github.com/plotly/plotly.py/pull/2544)).
27+
- Made the Plotly Express `trendline` argument more robust and made it work with datetime `x` values ([#2554](https://github.com/plotly/plotly.py/pull/2554))
28+
- Fixed bug in `px.sunburst` and `px.treemap`: when the `color` and `values` arguments correspond to the same column, a different aggregation function has to be used for the two arguments ([#2591](https://github.com/plotly/plotly.py/pull/2591))
29+
- Plotly Express wide mode now accepts mixed integer and float columns ([#2598](https://github.com/plotly/plotly.py/pull/2598))
30+
- Plotly Express `range_(x|y)` should not impact the unlinked range of marginal subplots ([#2600](https://github.com/plotly/plotly.py/pull/2600))
31+
- `px.line` now sets `line_group=<variable>` in wide mode by default ([#2599](https://github.com/plotly/plotly.py/pull/2599))
32+
- Corrected some regex warnings ([#2577](https://github.com/plotly/plotly.py/pull/2577)), with thanks to [@georgevdd](https://github.com/georgevdd) for the contribution!
1633

1734
## [4.8.1] - 2020-05-28
1835

Diff for: README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
## Quickstart
3535

36-
`pip install plotly==4.8.1`
36+
`pip install plotly==4.8.2`
3737

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

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

8484
```
85-
pip install plotly==4.8.1
85+
pip install plotly==4.8.2
8686
```
8787

8888
or conda.
8989

9090
```
91-
conda install -c plotly plotly=4.8.1
91+
conda install -c plotly plotly=4.8.2
9292
```
9393

9494
### Jupyter Notebook Support
@@ -125,10 +125,10 @@ Then run the following commands to install the required JupyterLab extensions (n
125125

126126
```
127127
# Basic JupyterLab renderer support
128-
jupyter labextension install [email protected].1
128+
jupyter labextension install [email protected].2
129129
130130
# OPTIONAL: Jupyter widgets extension for FigureWidget support
131-
jupyter labextension install @jupyter-widgets/jupyterlab-manager [email protected].1
131+
jupyter labextension install @jupyter-widgets/jupyterlab-manager [email protected].2
132132
```
133133

134134
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==4.8.1
2+
plotly==4.8.2
33
jupyter
44
notebook
55
pandas==1.0.3

Diff for: contributing.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ the structure of the code and of the repository.
6464
https://github.com/plotly/plotly.py/issues/1965. If you have writing skills,
6565
the wording of existing examples can also be improved in places.
6666

67-
Contributing code or documentation are not the only way to contribute! You can
67+
Contributing code or documentation is not the only way to contribute! You can
6868
also contribute to the project by
6969

7070
- reporting bugs (see below).
@@ -151,7 +151,12 @@ complete installation and avoid gdal-config errors.
151151
```
152152
This will ensure that the installed packages links to your local development
153153
directory, meaning that all changes you make reflect directly in your
154-
environment (don't forget to restart the Jupyter kernel though!).
154+
environment (don't forget to restart the Jupyter kernel though!). For more
155+
information see the
156+
[`setuptools`](https://setuptools.readthedocs.io/en/latest/setuptools.html#development-mode)
157+
and
158+
[`pip`](https://pip.pypa.io/en/stable/reference/pip_install/#install-editable)
159+
documentation on _development mode_.
155160

156161
### ipywidgets development install
157162

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.8.1"
31+
release = "4.8.2"
3232

3333

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

Diff for: doc/apidoc/plotly.graph_objects.rst

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Simple Traces
4343
Bar
4444
Pie
4545
Heatmap
46+
Heatmapgl
4647
Image
4748
Contour
4849
Table

Diff for: doc/python/3d-scatter-plots.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ fig.update_layout(margin=dict(l=0, r=0, b=0, t=0))
7676

7777
#### Basic 3D Scatter Plot
7878

79-
If Plotly Express does not provide a good starting point, it is also possible to use the more generic `go.Scatter3D` from `plotly.graph_objs`.
79+
If Plotly Express does not provide a good starting point, it is also possible to use [the more generic `go.Scatter3D` class from `plotly.graph_objects`](/python/graph-objects/).
8080
Like the [2D scatter plot](https://plotly.com/python/line-and-scatter/) `go.Scatter`, `go.Scatter3d` plots individual data in three-dimensional space.
8181

8282
```python

Diff for: doc/python/animations.md

+6
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ fig = px.bar(df, x="continent", y="pop", color="continent",
5151
fig.show()
5252
```
5353

54+
### Current Animation Limitations and Caveats
55+
56+
* Animations are designed to work well when each row of input is present across all animation frames, and when categorical values mapped to symbol, color and facet are constant across frames. Animations *may be misleading or inconsistent* if these constraints are not met.
57+
* Although Plotly Express supports animation for many chart and map types, smooth inter-frame transitions are today only possible for scatter and bar
58+
* Plotly Express will not automatically compute the union of all x/y/color ranges, so these must be specified manually to avoid scale jumps across frames
59+
5460
#### Animated figures with Graph Objects
5561

5662
The remainder of this section describes the low-level API for constructing animated figures manually.

Diff for: doc/python/axes.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jupyter:
2929
language: python
3030
layout: base
3131
name: Axes
32-
order: 12
32+
order: 13
3333
permalink: python/axes/
3434
thumbnail: thumbnail/axes.png
3535
---

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ To learn more, see the _link to px.bar reference page_.
9999

100100
#### Basic Bar Chart with plotly.graph_objects
101101

102-
If Plotly Express does not provide a good starting point, it is also possible to use the more generic `go.Bar` function from `plotly.graph_objects`.
102+
If Plotly Express does not provide a good starting point, it is also possible to use [the more generic `go.Bar` class from `plotly.graph_objects`](/python/graph-objects/).
103103

104104
```python
105105
import plotly.graph_objects as go

Diff for: doc/python/box-plots.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ fig.show()
134134

135135
## Box plot with go.Box
136136

137-
If Plotly Express does not provide a good starting point, it is also possible to use the more generic `go.Box` function from `plotly.graph_objects`. All available options for `go.Box` are described in the reference page https://plotly.com/python/reference/#box.
137+
If Plotly Express does not provide a good starting point, it is also possible to use [the more generic `go.Box` class from `plotly.graph_objects`](/python/graph-objects/). All available options for `go.Box` are described in the reference page https://plotly.com/python/reference/#box.
138138

139139
### Basic Box Plot
140140

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ fig.show()
5252

5353
## Bubble Chart with plotly.graph_objects
5454

55-
If Plotly Express does not provide a good starting point, it is also possible to use the more generic `go.Scatter` from `plotly.graph_objects`, and define the size of markers to create a bubble chart. All of the available options are described in the scatter section of the reference page: https://plotly.com/python/reference#scatter.
55+
If Plotly Express does not provide a good starting point, it is also possible to use [the more generic `go.Scatter` class from `plotly.graph_objects`](/python/graph-objects/), and define the size of markers to create a bubble chart. All of the available options are described in the scatter section of the reference page: https://plotly.com/python/reference#scatter.
5656

5757
### Simple Bubble Chart
5858

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jupyter:
3030
language: python
3131
layout: base
3232
name: Built-in Continuous Color Scales
33-
order: 26
33+
order: 27
3434
permalink: python/builtin-colorscales/
3535
thumbnail: thumbnail/heatmap_colorscale.jpg
3636
v4upgrade: true

Diff for: doc/python/colorscales.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jupyter:
3030
language: python
3131
layout: base
3232
name: Continuous Color Scales and Color Bars
33-
order: 19
33+
order: 20
3434
permalink: python/colorscales/
3535
redirect_from: python/logarithmic-color-scale/
3636
thumbnail: thumbnail/heatmap_colorscale.jpg

Diff for: doc/python/configuration-options.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jupyter:
2828
language: python
2929
layout: base
3030
name: Configuration
31-
order: 8
31+
order: 9
3232
page_type: u-guide
3333
permalink: python/configuration-options/
3434
thumbnail: thumbnail/modebar-icons.png

Diff for: doc/python/creating-and-updating-figures.md

+31-48
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,13 @@ jupyter:
3737
v4upgrade: true
3838
---
3939

40-
### Representing Figures
40+
The `plotly` Python package exists to create, manipulate and [render](/python/renderers/) graphical figures (i.e. charts, plots, maps and diagrams) represented by [data structures also referred to as figures](/python/figure-structure/). The rendering process uses the [Plotly.js JavaScript library](https://plotly.com/javascript/) under the hood although Python developers using this module very rarely need to interact with the Javascript library directly, if ever. Figures can be represented in Python either as dicts or as instances of the `plotly.graph_objects.Figure` class, and are serialized as text in [JavaScript Object Notation (JSON)](https://json.org/) before being passed to Plotly.js.
4141

42-
The goal of the plotly.py package is to provide a pleasant Python interface for creating figure specifications which are displayed by the [plotly.js](https://plot.ly/javascript) JavaScript graphing library.
42+
> Note: the recommended entry-point into the plotly package is the [high-level plotly.express module, also known as Plotly Express](/python/plotly-express/), which consists of Python functions which return fully-populated `plotly.graph_objects.Figure` objects. This page exists to document the structure of the data structure that these objects represent for users who wish to understand more about how to customize them, or assemble them from other `plotly.graph_objects` components.
4343
44-
In the context of the plotly.js library, a figure is specified by a declarative [JSON](https://www.json.org/json-en.html) data structure.
44+
### Figures As Dictionaries
4545

46-
Therefore, you should always keep in mind as you are creating and updating figures using the plotly.py package that its ultimate goal is to help users produce Python [dictionaries](https://docs.python.org/3/tutorial/datastructures.html#dictionaries) that can be automatically [serialized](https://en.wikipedia.org/wiki/Serialization) into the JSON data structure that the plotly.js graphing library understands.
47-
48-
#### Figures As Dictionaries
49-
50-
The `fig` dictonary in the example below describes a figure. It contains a single `bar` trace and a title.
46+
At a low level, figures can be represented as dictionaries and displayed using functions from the `plotly.io` module. The `fig` dictonary in the example below describes a figure. It contains a single `bar` trace and a title.
5147

5248
```python
5349
fig = dict({
@@ -63,37 +59,21 @@ import plotly.io as pio
6359
pio.show(fig)
6460
```
6561

66-
Let's take a closer look at structure of the `fig` dictionary in order to better understand how `plotly.py` figures are built.
67-
68-
##### The `"data"` Key
69-
70-
The `"data"` key stores the value of list which describes the trace or traces which make up a figure. It is still a list even if the figure only contains one trace, as in the example above.
71-
72-
Each trace in the list stored by the `"data"` key is itself defined by a dictionary. The type of the trace (`"bar"`, `"scatter"`, `"contour"`, etc...) is specified with a `"type"` key, and the rest of the keys in a trace specification dictionary (`x`, `y`, etc...) are used to define the properties specific to the trace of that type.
73-
74-
##### The `"layout"` Key
62+
### Figures as Graph Objects
7563

76-
The`"layout"` key stores a dictionary that specifies properties related to customizing how the figure looks, such as its title, typography, margins, axes, annotations, shapes, legend and more. In contrast to trace configuration options, which apply only to individual traces, layout configuration options apply to the figure as a whole.
64+
The [`plotly.graph_objects` module provides an automatically-generated hierarchy of classes](https://plotly.com/python-api-reference/plotly.graph_objects.html) called ["graph objects"](/python/graph-objects/) that may be used to represent figures, with a top-level class `plotly.graph_objects.Figure`.
7765

78-
The [_Full Reference_](https://plot.ly/python/reference/) page contains descriptions of all of the supported trace and layout attributes and configuration options.
66+
> Note that the *recommended alternative* to working with Python dictionaries is to [create entire figures at once using Plotly Express](/python/plotly-express/) and to manipulate the resulting `plotly.graph_objects.Figure` objects as described in this page, wherever possible, rather than to assemble figures bottom-up from underlying graph objects. See ["When to use Graph Objects"](/python/graph-objects/).
7967
80-
If working from the _Full Reference_ to build figures as Python dictionaries and lists suites your needs, go for it!
81-
82-
This is a perfectly valid way to use `plotly.py` to build figures. On the other hand, if you would like to use an API that offers you a bit more assistance in the figure creation process, read on to learn about `graph objects`.
83-
84-
#### Figures as Graph Objects
85-
86-
As an alternative to working with Python dictionaries, the `plotly.py` graphing library provides a hierarchy of classes called "graph objects" that may be used to construct figures. Graph objects have several benefits compared to plain Python dictionaries.
68+
Graph objects have several benefits compared to plain Python dictionaries.
8769

8870
1. Graph objects provide precise data validation. If you provide an invalid property name or an invalid property value as the key to a graph object, an exception will be raised with a helpful error message describing the problem. This is not the case if you use plain Python dictionaries and lists to build your figures.
89-
90-
2. Graph objects contain descriptions of each valid property as Python `docstrings`. You can use these `docstrings` in the development environment of your choice to learn about the available properties as an alternative to consulting the online [Full Reference](/python/reference/).
91-
71+
2. Graph objects contain descriptions of each valid property as Python docstrings, with a [full API reference available](https://plotly.com/python-api-reference/). You can use these docstrings in the development environment of your choice to learn about the available properties as an alternative to consulting the online [Full Reference](/python/reference/).
9272
3. Properties of graph objects can be accessed using both dictionary-style key lookup (e.g. `fig["layout"]`) or class-style property access (e.g. `fig.layout`).
73+
4. Graph objects support higher-level convenience functions for making updates to already constructed figures (`.update_layout()`, `.add_trace()` etc) as described below.
74+
5. Graph object constructors and update methods accept "magic underscores" (e.g. `go.Figure(layout_title_text="The Title")` rather than `dict(layout=dict(title=dict(text="The Title")))`) for more compact code, as described below.
75+
6. Graph objects support attached rendering (`.show()`) and exporting functions (`.write_image()`) that automatically invoke the appropriate functions from [the `plotly.io` module](https://plotly.com/python-api-reference/plotly.io.html).
9376

94-
4. Graph objects support higher-level convenience functions for making updates to already constructed figures, as described below.
95-
96-
**Graph objects are stored in a hierarchy of modules under the `plotly.graph_objects` package, so make sure to remember to `import plotly.graph_objects as go` when you want to use them.**
9777

9878
Below you can find an example of one way that the figure in the example above could be specified using a graph object instead of a dictionary.
9979

@@ -151,35 +131,38 @@ print("\n\n")
151131

152132
This section summarizes several ways to create new graph object figures with the `plotly.py` graphing library.
153133

154-
#### Graph Objects `Figure` Constructor
134+
> The *recommended way* to create figures and populate them is to use [Plotly Express](/python/plotly-express/) but this page documents various other options for completeness
155135
156-
As demonstrated above, you can build a complete figure by passing trace and layout specifications to the `plotly.graph_objects.Figure` constructor. These trace and layout specifications can be either dictionaries or graph objects.
157136

158-
In the following example, the traces are specified using graph objects and the layout is specified as a dictionary.
137+
#### Plotly Express
138+
139+
[Plotly Express](https://plot.ly/python/plotly-express/) (included as the `plotly.express` module) is a high-level data visualization API that produces fully-populated graph object figures in single function-calls.
159140

160141
```python
161-
import plotly.graph_objects as go
142+
import plotly.express as px
162143

163-
fig = go.Figure(
164-
data=[go.Bar(x=[1, 2, 3], y=[1, 3, 2])],
165-
layout=dict(title=dict(text="A Figure Specified By A Graph Object"))
166-
)
144+
df = px.data.iris()
145+
fig = px.scatter(df, x="sepal_width", y="sepal_length", color="species", title="A Plotly Express Figure")
146+
147+
# If you print the figure, you'll see that it's just a regular figure with data and layout
148+
# print(fig)
167149

168150
fig.show()
169151
```
170152

171-
#### Plotly Express
153+
#### Graph Objects `Figure` Constructor
172154

173-
[Plotly Express](https://plot.ly/python/plotly-express/) (included as the `plotly.express` module) is a high-level data exploration API that produces graph object figures.
155+
As demonstrated above, you can build a complete figure by passing trace and layout specifications to the `plotly.graph_objects.Figure` constructor. These trace and layout specifications can be either dictionaries or graph objects.
174156

175-
```python
176-
import plotly.express as px
157+
In the following example, the traces are specified using graph objects and the layout is specified as a dictionary.
177158

178-
df = px.data.iris()
179-
fig = px.scatter(df, x="sepal_width", y="sepal_length", color="species", title="A Plotly Express Figure")
159+
```python
160+
import plotly.graph_objects as go
180161

181-
# If you print fig, you'll see that it's just a regular figure with data and layout
182-
# print(fig)
162+
fig = go.Figure(
163+
data=[go.Bar(x=[1, 2, 3], y=[1, 3, 2])],
164+
layout=dict(title=dict(text="A Figure Specified By A Graph Object"))
165+
)
183166

184167
fig.show()
185168
```

Diff for: doc/python/discrete-color.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jupyter:
3030
language: python
3131
layout: base
3232
name: Discrete Colors
33-
order: 27
33+
order: 28
3434
permalink: python/discrete-color/
3535
thumbnail: thumbnail/heatmap_colorscale.jpg
3636
v4upgrade: true

Diff for: doc/python/dropdowns.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ fig.update_scenes(
147147
aspectmode="manual"
148148
)
149149

150-
# Add drowdowns
150+
# Add dropdowns
151151
button_layer_1_height = 1.08
152152
fig.update_layout(
153153
updatemenus=[

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jupyter:
2828
language: python
2929
layout: base
3030
name: Figure Factories
31-
order: 31
31+
order: 32
3232
permalink: python/figure-factories/
3333
thumbnail: thumbnail/streamline.jpg
3434
---

0 commit comments

Comments
 (0)