Skip to content

Commit 5a66bbf

Browse files
committed
Merge branch 'hover-format-or-skip' of https://github.com/plotly/plotly.py into hover-format-or-skip
2 parents 7170a52 + 135c412 commit 5a66bbf

File tree

10,135 files changed

+623696
-599921
lines changed

Some content is hidden

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

10,135 files changed

+623696
-599921
lines changed

Diff for: binder/requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
jupytext
2-
plotly==4.5.4
2+
plotly==4.6.0
33
jupyter
44
notebook
55
pandas

Diff for: contributing.md

+15-7
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# Contributing
22

33
Thank you for contributing to plotly.py! We are actively looking for
4-
diverse contributors, with diverse background and skills.
4+
diverse contributors, with diverse background and skills.
55

66
This guide start by a general description of the different ways to contribute
77
to plotly.py, then we explain some technical aspects of preparing your
8-
contribution.
8+
contribution.
99

1010
## Code of Conduct
1111

12-
Please check out the [Code of Conduct](CODE_OF_CONDUCT.md). Don't tl:dr; it,
12+
Please check out the [Code of Conduct](CODE_OF_CONDUCT.md). Don't tl:dr; it,
1313
but the general idea is to be nice.
1414

1515
## What are the different ways to contribute?
@@ -37,7 +37,7 @@ the structure of the code and of the repository.
3737
- the `plotly.figure_factory` module provides Python "recipes" for building
3838
advanced visualizations, such as Gantt charts, annotated heatmaps, etc.
3939
Figure factories are one of the easiest entry points into plotly.py, since
40-
they consist of Python-only code, with standalone, well-separated functions.
40+
they consist of Python-only code, with standalone, well-separated functions.
4141
However, please note that some of the figure factories become less relevant
4242
as we are introducing more features into `plotly.express`. Some issues in the
4343
tracker are labeled "figure_factory" and can be good issues to work on. More
@@ -70,14 +70,14 @@ also contribute to the project by
7070
- reporting bugs (see below).
7171

7272
- submitting feature requests (maybe we'll convince you to contribute it as a
73-
pull request!).
73+
pull request!).
7474

7575
- helping other users on the [community forum](https://community.plot.ly/).
7676
Join the list of [nice people](https://community.plot.ly/u) helping other
7777
plotly users :-).
7878

7979
We also recommend reading the great
80-
[how to contribute to open source](https://opensource.guide/how-to-contribute/)
80+
[how to contribute to open source](https://opensource.guide/how-to-contribute/)
8181
guide.
8282

8383
## Have a Bug Report?
@@ -98,7 +98,7 @@ Below we explain the technical aspects of contributing. It is not strictly neces
9898

9999
Note that if you are modifying a single documentation page, you can do it
100100
directly on Github by clicking on the "Edit this page on GitHub" link, without
101-
cloning the repository.
101+
cloning the repository.
102102

103103
## Setup a Development Environment
104104

@@ -206,6 +206,7 @@ First update the version of the `plotly.js` dependency in `packages/javascript/p
206206
Then run the `updateplotlyjs` command with:
207207

208208
```bash
209+
$ cd packages/python/plotly
209210
$ python setup.py updateplotlyjs
210211
```
211212

@@ -214,6 +215,13 @@ the `plotly/plotly.js` GitHub repository (and place them in
214215
`plotly/package_data`). It will then regenerate all of the `graph_objs`
215216
classes based on the new schema.
216217

218+
For dev branches, it is also possible to use `updateplotlyjsdev --devrepo reponame --devbranch branchname` to update to development versions of `plotly.js`. This will fetch the `plotly.js` in the CircleCI artifact of the branch `branchname` of the repo `reponame`. If `--devrepo` or `--devbranch` are omitted, `updateplotlyjsdev` defaults using `plotly/plotly.js` and `master` respectively. For example, to update to a version from a pull request to the `plotly/plotly.js` repo that is numbered 555, run:
219+
220+
```bash
221+
$ cd packages/python/plotly
222+
$ python setup.py updateplotlyjsdev --devbranch pull/555
223+
```
224+
217225
## Testing
218226

219227
We take advantage of two tools to run tests:

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.5.4"
31+
release = "4.6.0"
3232

3333

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

Diff for: doc/python/2D-Histogram.md

+68-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.2'
9-
jupytext_version: 1.3.0
9+
jupytext_version: 1.3.1
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.7.5
23+
version: 3.6.8
2424
plotly:
2525
description: How to make 2D Histograms in Python with Plotly.
2626
display_as: statistical
@@ -30,9 +30,75 @@ jupyter:
3030
order: 6
3131
page_type: u-guide
3232
permalink: python/2D-Histogram/
33+
redirect_from:
34+
- python/2d-histogram/
35+
- python/2d-histograms/
3336
thumbnail: thumbnail/histogram2d.jpg
3437
---
3538

39+
## 2D Histograms or Density Heatmaps
40+
41+
A 2D histogram, also known as a density heatmap, is the 2-dimensional generalization of a [histogram](/python/histograms/) which resembles a [heatmap](/python/heatmaps/) but is computed by grouping a set of points specified by their `x` and `y` coordinates into bins, and applying an aggregation function such as `count` or `sum` (if `z` is provided) to compute the color of the tile representing the bin. This kind of visualization (and the related [2D histogram contour, or density contour](https://plotly.com/python/2d-histogram-contour/)) is often used to manage over-plotting, or situations where showing large data sets as [scatter plots](/python/line-and-scatter/) would result in points overlapping each other and hiding patterns. For data sets of more than a few thousand points, a better approach than the ones listed here would be to [use Plotly with Datashader](/python/datashader/) to precompute the aggregations before displaying the data with Plotly.
42+
43+
## Density Heatmaps with Plotly Express
44+
45+
[Plotly Express](/python/plotly-express/) is the easy-to-use, high-level interface to Plotly, which [operates on "tidy" data](/python/px-arguments/) and produces [easy-to-style figures](/python/styling-plotly-express/). The Plotly Express function `density_heatmap()` can be used to produce density heatmaps.
46+
47+
```python
48+
import plotly.express as px
49+
df = px.data.tips()
50+
51+
fig = px.density_heatmap(df, x="total_bill", y="tip")
52+
fig.show()
53+
```
54+
55+
The number of bins can be controlled with `nbinsx` and `nbinsy` and the [color scale](/python/colorscales/) with `color_continuous_scale`.
56+
57+
```python
58+
import plotly.express as px
59+
df = px.data.tips()
60+
61+
fig = px.density_heatmap(df, x="total_bill", y="tip", nbinsx=20, nbinsy=20, color_continuous_scale="Viridis")
62+
fig.show()
63+
```
64+
65+
Marginal plots can be added to visualize the 1-dimensional distributions of the two variables. Here we use a marginal [`histogram`](/python/histograms/). Other allowable values are `violin`, `box` and `rug`.
66+
67+
```python
68+
import plotly.express as px
69+
df = px.data.tips()
70+
71+
fig = px.density_heatmap(df, x="total_bill", y="tip", marginal_x="histogram", marginal_y="histogram")
72+
fig.show()
73+
```
74+
75+
Density heatmaps can also be [faceted](/python/facet-plots/):
76+
77+
```python
78+
import plotly.express as px
79+
df = px.data.tips()
80+
81+
fig = px.density_heatmap(df, x="total_bill", y="tip", facet_row="sex", facet_col="smoker")
82+
fig.show()
83+
```
84+
85+
### Other aggregation functions than `count`
86+
87+
By passing in a `z` value and a `histfunc`, density heatmaps can perform basic aggregation operations. Here we show average Sepal Length grouped by Petal Length and Petal Width for the Iris dataset.
88+
89+
```python
90+
import plotly.express as px
91+
df = px.data.iris()
92+
93+
fig = px.density_heatmap(df, x="petal_length", y="petal_width", z="sepal_length", histfunc="avg")
94+
fig.show()
95+
```
96+
97+
### 2D Histograms with Graph Objects
98+
99+
To build this kind of plot without using Plotly Express, we can use the `go.Histogram2d` class.
100+
101+
36102
### 2D Histogram of a Bivariate Normal Distribution ###
37103

38104
```python

Diff for: doc/python/2d-histogram-contour.md

+67-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ jupyter:
55
text_representation:
66
extension: .md
77
format_name: markdown
8-
format_version: '1.1'
9-
jupytext_version: 1.1.1
8+
format_version: '1.2'
9+
jupytext_version: 1.3.1
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.7
23+
version: 3.6.8
2424
plotly:
2525
description: How to make 2D Histogram Contour plots in Python with Plotly.
2626
display_as: statistical
@@ -30,9 +30,73 @@ jupyter:
3030
order: 12
3131
page_type: u-guide
3232
permalink: python/2d-histogram-contour/
33+
redirect_from: python/2d-density-plots/
3334
thumbnail: thumbnail/hist2dcontour.png
3435
---
3536

37+
## 2D Histogram Contours or Density Contours
38+
39+
A 2D histogram contour plot, also known as a density contour plot, is a 2-dimensional generalization of a [histogram](/python/histograms/) which resembles a [contour plot](/python/contour-plots/) but is computed by grouping a set of points specified by their `x` and `y` coordinates into bins, and applying an aggregation function such as `count` or `sum` (if `z` is provided) to compute the value to be used to compute contours. This kind of visualization (and the related [2D histogram, or density heatmap](/python/2d-histogram/)) is often used to manage over-plotting, or situations where showing large data sets as [scatter plots](/python/line-and-scatter/) would result in points overlapping each other and hiding patterns.
40+
41+
## Density Contours with Plotly Express
42+
43+
[Plotly Express](/python/plotly-express/) is the easy-to-use, high-level interface to Plotly, which [operates on "tidy" data](/python/px-arguments/) and produces [easy-to-style figures](/python/styling-plotly-express/). The Plotly Express function `density_contour()` can be used to produce density contours.
44+
45+
```python
46+
import plotly.express as px
47+
df = px.data.tips()
48+
49+
fig = px.density_contour(df, x="total_bill", y="tip")
50+
fig.show()
51+
```
52+
53+
Marginal plots can be added to visualize the 1-dimensional distributions of the two variables. Here we use a marginal [`histogram`](/python/histograms/). Other allowable values are `violin`, `box` and `rug`.
54+
55+
```python
56+
import plotly.express as px
57+
df = px.data.tips()
58+
59+
fig = px.density_contour(df, x="total_bill", y="tip", marginal_x="histogram", marginal_y="histogram")
60+
fig.show()
61+
```
62+
63+
Density contours can also be [faceted](/python/facet-plots/) and [discretely colored](/python/discrete-color/):
64+
65+
```python
66+
import plotly.express as px
67+
df = px.data.tips()
68+
69+
fig = px.density_contour(df, x="total_bill", y="tip", facet_col="sex", color="smoker")
70+
fig.show()
71+
```
72+
73+
Plotly Express density contours can be [continuously-colored](/python/colorscales/) and labeled:
74+
75+
```python
76+
import plotly.express as px
77+
df = px.data.tips()
78+
79+
fig = px.density_contour(df, x="total_bill", y="tip")
80+
fig.update_traces(contours_coloring="fill", contours_showlabels = True)
81+
fig.show()
82+
```
83+
84+
### Other aggregation functions than `count`
85+
86+
By passing in a `z` value and a `histfunc`, density contours can perform basic aggregation operations. Here we show average Sepal Length grouped by Petal Length and Petal Width for the Iris dataset.
87+
88+
```python
89+
import plotly.express as px
90+
df = px.data.iris()
91+
92+
fig = px.density_contour(df, x="petal_length", y="petal_width", z="sepal_length", histfunc="avg")
93+
fig.show()
94+
```
95+
96+
### 2D Histograms with Graph Objects
97+
98+
To build this kind of plot without using Plotly Express, we can use the `go.Histogram2d` class.
99+
36100
#### Basic 2D Histogram Contour
37101

38102
```python

0 commit comments

Comments
 (0)