Skip to content

Commit c56725a

Browse files
Update ternary-plots.md
1 parent 3824ec2 commit c56725a

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

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

+29-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,35 @@ jupyter:
3333
thumbnail: thumbnail/v4-migration.png
3434
---
3535

36-
### Basic Ternary Plot with Markers
36+
## Ternary Plots
37+
38+
A ternary plot depicts the ratios of three variables as positions in an equilateral triangle.
39+
40+
## Ternary scatter plot with Plotly Express
41+
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/).
43+
44+
Here we use `px.scatter_ternary` to visualize thre three-way split between the three major candidates in a municipal election.
45+
46+
```python
47+
import plotly.express as px
48+
df = px.data.election()
49+
fig = px.scatter_ternary(df, a="Joly", b="Coderre", c="Bergeron")
50+
fig.show()
51+
```
52+
53+
We can scale and color the markers to produce a ternary bubble chart.
54+
55+
```python
56+
import plotly.express as px
57+
df = px.data.election()
58+
fig = px.scatter_ternary(df, a="Joly", b="Coderre", c="Bergeron", hover_name="district",
59+
color="winner", size="total", size_max=15,
60+
color_discrete_map = {"Joly": "blue", "Bergeron": "green", "Coderre":"red"} )
61+
fig.show()
62+
```
63+
64+
### Ternary scatter plot with Plotly Graph Objects
3765

3866
```python
3967
import plotly.graph_objects as go

0 commit comments

Comments
 (0)