Skip to content

Commit 44f0032

Browse files
Merge pull request #2895 from plotly/add-five-snippets
Python Docs Dash Snippets: hover-text-and-formatting, pie-charts, choropleth-maps, box-plots, discrete-color
2 parents 052c249 + 6a12fba commit 44f0032

File tree

5 files changed

+61
-13
lines changed

5 files changed

+61
-13
lines changed

doc/python/box-plots.md

Lines changed: 14 additions & 2 deletions
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.6.0
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.6
2424
plotly:
2525
description: How to make Box Plots in Python with Plotly.
2626
display_as: statistical
@@ -60,6 +60,18 @@ fig = px.box(df, x="time", y="total_bill")
6060
fig.show()
6161
```
6262

63+
### Box Plots in Dash
64+
65+
[Dash](https://plotly.com/dash/) is the best way to build analytical apps in Python using Plotly figures. To run the app below, run `pip install dash`, click "Download" to get the code and run `python app.py`.
66+
67+
Get started with [the official Dash docs](https://dash.plotly.com/installation) and **learn how to effortlessly [style](https://plotly.com/dash/design-kit/) & [deploy](https://plotly.com/dash/app-manager/) apps like this with <a style="color:red;" href="https://plotly.com/dash/">Dash Enterprise</a>.**
68+
69+
```python hide_code=true
70+
from IPython.display import IFrame
71+
snippet_url = 'https://dash-gallery.plotly.host/python-docs-dash-snippets/'
72+
IFrame(snippet_url + 'box-plots', width='100%', height=630)
73+
```
74+
6375
### Display the underlying data
6476

6577
With the `points` argument, display underlying data points with either all points (`all`), outliers only (`outliers`, default), or none of them (`False`).

doc/python/choropleth-maps.md

Lines changed: 14 additions & 2 deletions
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.4.2
9+
jupytext_version: 1.6.0
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.7
23+
version: 3.7.6
2424
plotly:
2525
description: How to make choropleth maps in Python with Plotly.
2626
display_as: maps
@@ -143,6 +143,18 @@ fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
143143
fig.show()
144144
```
145145

146+
### Choropleth maps in Dash
147+
148+
[Dash](https://plotly.com/dash/) is the best way to build analytical apps in Python using Plotly figures. To run the app below, run `pip install dash`, click "Download" to get the code and run `python app.py`.
149+
150+
Get started with [the official Dash docs](https://dash.plotly.com/installation) and **learn how to effortlessly [style](https://plotly.com/dash/design-kit/) & [deploy](https://plotly.com/dash/app-manager/) apps like this with <a style="color:red;" href="https://plotly.com/dash/">Dash Enterprise</a>.**
151+
152+
```python hide_code=true
153+
from IPython.display import IFrame
154+
snippet_url = 'https://dash-gallery.plotly.host/python-docs-dash-snippets/'
155+
IFrame(snippet_url + 'choropleth-maps', width='100%', height=630)
156+
```
157+
146158
### Discrete Colors
147159

148160
In addition to [continuous colors](/python/colorscales/), we can [discretely-color](/python/discrete-color/) our choropleth maps by setting `color` to a non-numerical column, like the name of the winner of an election.

doc/python/discrete-color.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,9 @@ fig.show()
101101

102102
### Discrete Colors in Dash
103103

104-
[Dash](https://plotly.com/dash/) is the best way to build analytical apps in Python using Plotly figures. With Dash, you can add radio buttons to control the color mode of your graph.
104+
[Dash](https://plotly.com/dash/) is the best way to build analytical apps in Python using Plotly figures. To run the app below, run `pip install dash`, click "Download" to get the code and run `python app.py`.
105105

106-
To run the app below, run `pip install dash`, click "Download" to get the code and run `python app.py`.
107-
108-
Get started now with [the official docs](https://dash.plotly.com/installation) and learn how you can effortlessly [style](https://plotly.com/dash/design-kit/) and [deploy](https://plotly.com/dash/app-manager/) apps like this with [Dash Enterprise](https://plotly.com/dash/).
106+
Get started with [the official Dash docs](https://dash.plotly.com/installation) and **learn how to effortlessly [style](https://plotly.com/dash/design-kit/) & [deploy](https://plotly.com/dash/app-manager/) apps like this with <a style="color:red;" href="https://plotly.com/dash/">Dash Enterprise</a>.**
109107

110108
```python hide_code=true
111109
from IPython.display import IFrame

doc/python/hover-text-and-formatting.md

Lines changed: 16 additions & 2 deletions
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.4.2
9+
jupytext_version: 1.6.0
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.7
23+
version: 3.7.6
2424
plotly:
2525
description: How to use hover text and formatting in Python with Plotly.
2626
display_as: file_settings
@@ -83,6 +83,20 @@ fig.update_layout(hovermode="x unified")
8383
fig.show()
8484
```
8585

86+
#### Control hovermode with Dash
87+
88+
[Dash](https://plotly.com/dash/) is the best way to build analytical apps in Python using Plotly figures. To run the app below, run `pip install dash`, click "Download" to get the code and run `python app.py`.
89+
90+
Get started with [the official Dash docs](https://dash.plotly.com/installation) and **learn how to effortlessly [style](https://plotly.com/dash/design-kit/) & [deploy](https://plotly.com/dash/app-manager/) apps like this with <a style="color:red;" href="https://plotly.com/dash/">Dash Enterprise</a>.**
91+
92+
Change the hovermode below and try hovering over the points:
93+
94+
```python hide_code=true
95+
from IPython.display import IFrame
96+
snippet_url = 'https://dash-gallery.plotly.host/python-docs-dash-snippets/'
97+
IFrame(snippet_url + 'hover-text-and-formatting', width='100%', height=630)
98+
```
99+
86100
#### Selecting a hovermode in a figure created with `plotly.graph_objects`
87101

88102
The hovermode is a property of the figure layout, so you can select a hovermode no matter how you created the figure, either with `plotly.express` or with `plotly.graph_objects`. Below is an example with a figure created with `plotly.graph_objects`. If you're not familiar with the structure of plotly figures, you can read [the tutorial on creating and updating plotly figures](/python/creating-and-updating-figures/).

doc/python/pie-charts.md

Lines changed: 15 additions & 3 deletions
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.6.0
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.3
23+
version: 3.7.6
2424
plotly:
2525
description: How to make Pie Charts.
2626
display_as: basic
@@ -64,6 +64,18 @@ fig = px.pie(df, values='tip', names='day')
6464
fig.show()
6565
```
6666

67+
### Pie chart in Dash
68+
69+
[Dash](https://plotly.com/dash/) is the best way to build analytical apps in Python using Plotly figures. To run the app below, run `pip install dash`, click "Download" to get the code and run `python app.py`.
70+
71+
Get started with [the official Dash docs](https://dash.plotly.com/installation) and **learn how to effortlessly [style](https://plotly.com/dash/design-kit/) & [deploy](https://plotly.com/dash/app-manager/) apps like this with <a style="color:red;" href="https://plotly.com/dash/">Dash Enterprise</a>.**
72+
73+
```python hide_code=true
74+
from IPython.display import IFrame
75+
snippet_url = 'https://dash-gallery.plotly.host/python-docs-dash-snippets/'
76+
IFrame(snippet_url + 'pie-charts', width='100%', height=630)
77+
```
78+
6779
### Setting the color of pie sectors with px.pie
6880

6981
```python
@@ -304,4 +316,4 @@ fig.show()
304316

305317
#### Reference
306318

307-
See https://plotly.com/python/reference/pie/ for more information and chart attribute options!
319+
See https://plotly.com/python/reference/pie/ for more information and chart attribute options!

0 commit comments

Comments
 (0)