Skip to content

Commit 00b0cc7

Browse files
authored
Merge pull request #9 from plotly/master
Merge doc prod2 (plotly#2179)
2 parents e6df5e5 + 9fb88c1 commit 00b0cc7

Some content is hidden

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

42 files changed

+442
-135
lines changed

Diff for: .circleci/config.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,8 @@ jobs:
425425
. venv/bin/activate
426426
echo ${mapbox_token} > python/.mapbox_token
427427
make -kj8 || make -kj8
428-
curl https://raw.githubusercontent.com/plotly/documentation/source-design-merge/front-matter-ci.py > front-matter-ci.py
429-
curl https://raw.githubusercontent.com/plotly/documentation/source-design-merge/check-or-enforce-order.py > check-or-enforce-order.py
428+
curl https://raw.githubusercontent.com/plotly/graphing-library-docs/master/front-matter-ci.py > front-matter-ci.py
429+
curl https://raw.githubusercontent.com/plotly/graphing-library-docs/master/check-or-enforce-order.py > check-or-enforce-order.py
430430
python front-matter-ci.py build/html
431431
python check-or-enforce-order.py build/html
432432
if [ "${CIRCLE_BRANCH}" == "doc-prod" ]; then
@@ -448,14 +448,14 @@ jobs:
448448
name: trigger doc build
449449
command: |
450450
if [ "${CIRCLE_BRANCH}" == "doc-prod" ]; then
451-
git clone --depth=1 --branch=source-design-merge https://github.com/plotly/documentation.git
452-
cd documentation
451+
git clone --depth=1 https://github.com/plotly/graphing-library-docs.git
452+
cd graphing-library-docs
453453
git config user.name plotlydocbot
454454
git config user.email [email protected]
455455
git commit --allow-empty -m "deploying https://github.com/plotly/plotly.py/commit/${CIRCLE_SHA1}"
456456
git push
457457
cd ..
458-
rm -rf documentation
458+
rm -rf graphing-library-docs
459459
fi
460460
461461
- run:

Diff for: binder/requirements.txt

+2
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@ psutil
1212
requests
1313
networkx
1414
scikit-image
15+
datashader
16+
pyarrow

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jupyter:
3535

3636
## 3D scatter plot with Plotly Express
3737

38-
[Plotly Express](/python/plotly-express/) is the easy-to-use, high-level interface to Plotly, which [operates on "tidy" data](/python/px-arguments/).
38+
[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/).
3939

4040
Like the [2D scatter plot](https://plot.ly/python/line-and-scatter/) `px.scatter`, the 3D function `px.scatter_3d` plots individual data in three-dimensional space.
4141

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ jupyter:
55
text_representation:
66
extension: .md
77
format_name: markdown
8-
format_version: '1.2'
8+
format_version: "1.2"
99
jupytext_version: 1.3.0
1010
kernelspec:
1111
display_name: Python 3
@@ -35,7 +35,7 @@ jupyter:
3535

3636
### Bar chart with Plotly Express
3737

38-
[Plotly Express](/python/plotly-express/) is the easy-to-use, high-level interface to Plotly, which [operates on "tidy" data](/python/px-arguments/).
38+
[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/).
3939

4040
With `px.bar`, each row of the DataFrame is represented as a rectangular mark.
4141

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

+15-14
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ jupyter:
55
text_representation:
66
extension: .md
77
format_name: markdown
8-
format_version: '1.2'
8+
format_version: "1.2"
99
jupytext_version: 1.3.1
1010
kernelspec:
1111
display_name: Python 3
@@ -31,16 +31,16 @@ jupyter:
3131
page_type: example_index
3232
permalink: python/box-plots/
3333
redirect_from:
34-
- /python/box/
35-
- /python/basic_statistics/
34+
- /python/box/
35+
- /python/basic_statistics/
3636
thumbnail: thumbnail/box.jpg
3737
---
3838

3939
A [box plot](https://en.wikipedia.org/wiki/Box_plot) is a statistical representation of numerical data through their quartiles. The ends of the box represent the lower and upper quartiles, while the median (second quartile) is marked by a line inside the box. For other statistical representations of numerical data, see [other statistical charts](https://plot.ly/python/statistical-charts/).
4040

4141
## Box Plot with `plotly.express`
4242

43-
[Plotly Express](/python/plotly-express/) is the easy-to-use, high-level interface to Plotly, which [operates on "tidy" data](/python/px-arguments/).
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/).
4444

4545
In a box plot created by `px.box`, the distribution of the column given as `y` argument is represented.
4646

@@ -73,13 +73,13 @@ fig.show()
7373

7474
### Choosing The Algorithm For Computing Quartiles
7575

76-
By default, quartiles for box plots are computed using the `linear` method (for more about linear interpolation, see #10 listed on [http://www.amstat.org/publications/jse/v14n3/langford.html](http://www.amstat.org/publications/jse/v14n3/langford.html) and [https://en.wikipedia.org/wiki/Quartile](https://en.wikipedia.org/wiki/Quartile) for more details).
76+
By default, quartiles for box plots are computed using the `linear` method (for more about linear interpolation, see #10 listed on [http://www.amstat.org/publications/jse/v14n3/langford.html](http://www.amstat.org/publications/jse/v14n3/langford.html) and [https://en.wikipedia.org/wiki/Quartile](https://en.wikipedia.org/wiki/Quartile) for more details).
7777

78-
However, you can also choose to use an `exclusive` or an `inclusive` algorithm to compute quartiles.
78+
However, you can also choose to use an `exclusive` or an `inclusive` algorithm to compute quartiles.
7979

80-
The *exclusive* algorithm uses the median to divide the ordered dataset into two halves. If the sample is odd, it does not include the median in either half. Q1 is then the median of the lower half and Q3 is the median of the upper half.
80+
The _exclusive_ algorithm uses the median to divide the ordered dataset into two halves. If the sample is odd, it does not include the median in either half. Q1 is then the median of the lower half and Q3 is the median of the upper half.
8181

82-
The *inclusive* algorithm also uses the median to divide the ordered dataset into two halves, but if the sample is odd, it includes the median in both halves. Q1 is then the median of the lower half and Q3 the median of the upper half.
82+
The _inclusive_ algorithm also uses the median to divide the ordered dataset into two halves, but if the sample is odd, it includes the median in both halves. Q1 is then the median of the lower half and Q3 the median of the upper half.
8383

8484
```python
8585
import plotly.express as px
@@ -92,7 +92,8 @@ fig.show()
9292
```
9393

9494
#### Difference Between Quartile Algorithms
95-
It can sometimes be difficult to see the difference between the linear, inclusive, and exclusive algorithms for computing quartiles. In the following example, the same dataset is visualized using each of the three different quartile computation algorithms.
95+
96+
It can sometimes be difficult to see the difference between the linear, inclusive, and exclusive algorithms for computing quartiles. In the following example, the same dataset is visualized using each of the three different quartile computation algorithms.
9697

9798
```python
9899
import plotly.express as px
@@ -103,7 +104,7 @@ df = pd.DataFrame(dict(
103104
linear=data,
104105
inclusive=data,
105106
exclusive=data
106-
)).melt(var_name="quartilemethod")
107+
)).melt(var_name="quartilemethod")
107108

108109

109110
fig = px.box(df, y="value", facet_col="quartilemethod", color="quartilemethod",
@@ -204,7 +205,7 @@ fig.show()
204205

205206
You can specify precomputed quartile attributes rather than using a built-in quartile computation algorithm.
206207

207-
This could be useful if you have already pre-computed those values or if you need to use a different algorithm than the ones provided.
208+
This could be useful if you have already pre-computed those values or if you need to use a different algorithm than the ones provided.
208209

209210
```python
210211
import plotly.graph_objects as go
@@ -217,9 +218,9 @@ fig.add_trace(go.Box(y=[
217218
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ]
218219
], name="Precompiled Quartiles"))
219220

220-
fig.update_traces(q1=[ 1, 2, 3 ], median=[ 4, 5, 6 ],
221-
q3=[ 7, 8, 9 ], lowerfence=[-1, 0, 1],
222-
upperfence=[5, 6, 7], mean=[ 2.2, 2.8, 3.2 ],
221+
fig.update_traces(q1=[ 1, 2, 3 ], median=[ 4, 5, 6 ],
222+
q3=[ 7, 8, 9 ], lowerfence=[-1, 0, 1],
223+
upperfence=[5, 6, 7], mean=[ 2.2, 2.8, 3.2 ],
223224
sd=[ 0.2, 0.4, 0.6 ], notchspan=[ 0.2, 0.4, 0.6 ] )
224225

225226
fig.show()

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jupyter:
3838

3939
A [bubble chart](https://en.wikipedia.org/wiki/Bubble_chart) is a scatter plot in which a third dimension of the data is shown through the size of markers. For other types of scatter plot, see the [line and scatter page](https://plot.ly/python/line-and-scatter/).
4040

41-
We first show a bubble chart example using Plotly Express. [Plotly Express](/python/plotly-express/) is the easy-to-use, high-level interface to Plotly, which [operates on "tidy" data](/python/px-arguments/). The size of markers is set from the dataframe column given as the `size` parameter.
41+
We first show a bubble chart example using Plotly Express. [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 size of markers is set from the dataframe column given as the `size` parameter.
4242

4343
```python
4444
import plotly.express as px

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Plotly figures made with `px.scatter_geo`, `px.line_geo` or `px.choropleth` func
3939

4040
### Bubble map with Plotly Express
4141

42-
[Plotly Express](/python/plotly-express/) is the easy-to-use, high-level interface to Plotly, which [operates on "tidy" data](/python/px-arguments/). With `px.scatter_geo`, each line of the dataframe is represented as a marker point. The column set as the `size` argument gives the size of markers.
42+
[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/). With `px.scatter_geo`, each line of the dataframe is represented as a marker point. The column set as the `size` argument gives the size of markers.
4343

4444
```python
4545
import plotly.express as px

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ The GeoJSON data is passed to the `geojson` argument, and the data is passed int
5656

5757
### Choropleth Map with plotly.express
5858

59-
[Plotly Express](/python/plotly-express/) is the easy-to-use, high-level interface to Plotly, which [operates on "tidy" data](/python/px-arguments/).
59+
[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/).
6060

6161
#### GeoJSON with `feature.id`
6262

Diff for: doc/python/datashader.md

+129
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
---
2+
jupyter:
3+
jupytext:
4+
notebook_metadata_filter: all
5+
text_representation:
6+
extension: .md
7+
format_name: markdown
8+
format_version: "1.2"
9+
jupytext_version: 1.3.1
10+
kernelspec:
11+
display_name: Python 3
12+
language: python
13+
name: python3
14+
language_info:
15+
codemirror_mode:
16+
name: ipython
17+
version: 3
18+
file_extension: .py
19+
mimetype: text/x-python
20+
name: python
21+
nbconvert_exporter: python
22+
pygments_lexer: ipython3
23+
version: 3.6.8
24+
plotly:
25+
description:
26+
How to use datashader to rasterize large datasets, and visualize
27+
the generated raster data with plotly.
28+
display_as: scientific
29+
language: python
30+
layout: base
31+
name: Plotly and Datashader
32+
order: 21
33+
page_type: u-guide
34+
permalink: python/datashader/
35+
thumbnail: thumbnail/datashader.jpg
36+
---
37+
38+
[datashader](https://datashader.org/) creates rasterized representations of large datasets for easier visualization, with a pipeline approach consisting of several steps: projecting the data on a regular grid, creating a color representation of the grid, etc.
39+
40+
### Passing datashader rasters as a mabox image layer
41+
42+
We visualize here the spatial distribution of taxi rides in New York City. A higher density
43+
is observed on major avenues. For more details about mapbox charts, see [the mapbox layers tutorial](/python/mapbox-layers). No mapbox token is needed here.
44+
45+
```python
46+
import pandas as pd
47+
df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/uber-rides-data1.csv')
48+
dff = df.query('Lat < 40.82').query('Lat > 40.70').query('Lon > -74.02').query('Lon < -73.91')
49+
50+
import datashader as ds
51+
cvs = ds.Canvas(plot_width=1000, plot_height=1000)
52+
agg = cvs.points(dff, x='Lon', y='Lat')
53+
# agg is an xarray object, see http://xarray.pydata.org/en/stable/ for more details
54+
coords_lat, coords_lon = agg.coords['Lat'].values, agg.coords['Lon'].values
55+
# Corners of the image, which need to be passed to mapbox
56+
coordinates = [[coords_lon[0], coords_lat[0]],
57+
[coords_lon[-1], coords_lat[0]],
58+
[coords_lon[-1], coords_lat[-1]],
59+
[coords_lon[0], coords_lat[-1]]]
60+
61+
from colorcet import fire
62+
import datashader.transfer_functions as tf
63+
img = tf.shade(agg, cmap=fire)[::-1].to_pil()
64+
65+
import plotly.express as px
66+
# Trick to create rapidly a figure with mapbox axes
67+
fig = px.scatter_mapbox(dff[:1], lat='Lat', lon='Lon', zoom=12)
68+
# Add the datashader image as a mapbox layer image
69+
fig.update_layout(mapbox_style="carto-darkmatter",
70+
mapbox_layers = [
71+
{
72+
"sourcetype": "image",
73+
"source": img,
74+
"coordinates": coordinates
75+
}]
76+
)
77+
fig.show()
78+
```
79+
80+
### Exploring correlations of a large dataset
81+
82+
Here we explore the flight delay dataset from https://www.kaggle.com/usdot/flight-delays. In order to get a visual impression of the correlation between features, we generate a datashader rasterized array which we plot using a `Heatmap` trace. It creates a much clearer visualization than a scatter plot of (even a fraction of) the data points, as shown below.
83+
84+
Note that instead of datashader it would theoretically be possible to create a [2d histogram](/python/2d-histogram-contour/) with plotly but this is not recommended here because you would need to load the whole dataset (5M rows !) in the browser for plotly.js to compute the heatmap, which is practically not tractable. Datashader offers the possibility to reduce the size of the dataset before passing it to the browser.
85+
86+
```python
87+
import plotly.graph_objects as go
88+
import pandas as pd
89+
import numpy as np
90+
import datashader as ds
91+
df = pd.read_parquet('https://raw.githubusercontent.com/plotly/datasets/master/2015_flights.parquet')
92+
fig = go.Figure(go.Scattergl(x=df['SCHEDULED_DEPARTURE'][::200],
93+
y=df['DEPARTURE_DELAY'][::200],
94+
mode='markers')
95+
)
96+
fig.update_layout(title_text='A busy plot')
97+
fig.show()
98+
```
99+
100+
```python
101+
import plotly.graph_objects as go
102+
import pandas as pd
103+
import numpy as np
104+
import datashader as ds
105+
df = pd.read_parquet('https://raw.githubusercontent.com/plotly/datasets/master/2015_flights.parquet')
106+
107+
cvs = ds.Canvas(plot_width=100, plot_height=100)
108+
agg = cvs.points(df, 'SCHEDULED_DEPARTURE', 'DEPARTURE_DELAY')
109+
x = np.array(agg.coords['SCHEDULED_DEPARTURE'])
110+
y = np.array(agg.coords['DEPARTURE_DELAY'])
111+
112+
# Assign nan to zero values so that the corresponding pixels are transparent
113+
agg = np.array(agg.values, dtype=np.float)
114+
agg[agg<1] = np.nan
115+
116+
fig = go.Figure(go.Heatmap(
117+
z=np.log10(agg), x=x, y=y,
118+
hoverongaps=False,
119+
hovertemplate='Scheduled departure: %{x:.1f}h <br>Depature delay: %{y} <br>Log10(Count): %{z}',
120+
colorbar=dict(title='Count (Log)', tickprefix='1.e')))
121+
fig.update_xaxes(title_text='Scheduled departure')
122+
fig.update_yaxes(title_text='Departure delay')
123+
fig.show()
124+
125+
```
126+
127+
```python
128+
129+
```

Diff for: doc/python/distplot.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jupyter:
3737

3838
Several representations of statistical distributions are available in plotly, such as [histograms](https://plot.ly/python/histograms/), [violin plots](https://plot.ly/python/violin/), [box plots](https://plot.ly/python/box-plots/) (see [the complete list here](https://plot.ly/python/statistical-charts/)). It is also possible to combine several representations in the same plot.
3939

40-
For example, the `plotly.express` function `px.histogram` can add a subplot with a different statistical representation than the histogram, given by the parameter `marginal`. [Plotly Express](/python/plotly-express/) is the easy-to-use, high-level interface to Plotly, which [operates on "tidy" data](/python/px-arguments/).
40+
For example, the `plotly.express` function `px.histogram` can add a subplot with a different statistical representation than the histogram, given by the parameter `marginal`. [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/).
4141

4242
```python
4343
import plotly.express as px

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

+3-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ jupyter:
55
text_representation:
66
extension: .md
77
format_name: markdown
8-
format_version: '1.1'
8+
format_version: "1.1"
99
jupytext_version: 1.1.1
1010
kernelspec:
1111
display_name: Python 3
@@ -35,11 +35,11 @@ jupyter:
3535

3636
#### Basic Dot Plot
3737

38-
Dot plots (also known as [Cleveland dot plots](https://en.wikipedia.org/wiki/Dot_plot_(statistics))) show changes between two (or more) points in time or between two (or more) conditions. Compared to a [bar chart](/python/bar-charts/), dot plots can be less cluttered and allow for an easier comparison between conditions.
38+
Dot plots (also known as [Cleveland dot plots](<https://en.wikipedia.org/wiki/Dot_plot_(statistics)>)) show changes between two (or more) points in time or between two (or more) conditions. Compared to a [bar chart](/python/bar-charts/), dot plots can be less cluttered and allow for an easier comparison between conditions.
3939

4040
For the same data, we show below how to create a dot plot using either `px.scatter` (for a tidy pandas DataFrame) or `go.Scatter`.
4141

42-
[Plotly Express](/python/plotly-express/) is the easy-to-use, high-level interface to Plotly, which [operates on "tidy" data](/python/px-arguments/).
42+
[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/).
4343

4444
```python
4545
import plotly.express as px
@@ -158,5 +158,4 @@ fig.show()
158158

159159
### Reference
160160

161-
162161
See https://plot.ly/python/reference/#scatter for more information and chart attribute options!

Diff for: doc/python/error-bars.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jupyter:
3535

3636
### Error Bars with Plotly Express
3737

38-
[Plotly Express](/python/plotly-express/) is the easy-to-use, high-level interface to Plotly, which [operates on "tidy" data](/python/px-arguments/). For functions representing 2D data points such as [`px.scatter`](https://plot.ly/python/line-and-scatter/), [`px.line`](https://plot.ly/python/line-charts/), [`px.bar`](https://plot.ly/python/bar-charts/) etc., error bars are given as a column name which is the value of the `error_x` (for the error on x position) and `error_y` (for the error on y position).
38+
[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/). For functions representing 2D data points such as [`px.scatter`](https://plot.ly/python/line-and-scatter/), [`px.line`](https://plot.ly/python/line-charts/), [`px.bar`](https://plot.ly/python/bar-charts/) etc., error bars are given as a column name which is the value of the `error_x` (for the error on x position) and `error_y` (for the error on y position).
3939

4040
```python
4141
import plotly.express as px

0 commit comments

Comments
 (0)