Skip to content

Commit 7756589

Browse files
Merge pull request #166 from plotly/facet_col_wrap
added example about facet_col_wrap, and one example for disabling axis sharing
2 parents 878d394 + 2b03f57 commit 7756589

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

python/facet-plots.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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 Facet and Trellis Plots in Python with Plotly.
2626
display_as: statistical
@@ -58,6 +58,18 @@ fig = px.bar(tips, x="size", y="total_bill", color="sex", facet_row="smoker")
5858
fig.show()
5959
```
6060

61+
### Wrapping Column Facets
62+
63+
When the facet dimension has a large number of unique values, it is possible to wrap columns using the `facet_col_wrap` argument.
64+
65+
```python
66+
import plotly.express as px
67+
df = px.data.gapminder()
68+
fig = px.scatter(df, x='gdpPercap', y='lifeExp', color='continent', size='pop',
69+
facet_col='year', facet_col_wrap=4)
70+
fig.show()
71+
```
72+
6173
### Histogram Facet Grids
6274

6375
```python
@@ -67,3 +79,27 @@ fig = px.histogram(tips, x="total_bill", y="tip", color="sex", facet_row="time",
6779
category_orders={"day": ["Thur", "Fri", "Sat", "Sun"], "time": ["Lunch", "Dinner"]})
6880
fig.show()
6981
```
82+
83+
### Facets with independent axes
84+
85+
By default, facet axes are linked together: zooming inside one of the facets will also zoom in the other facets. You can disable this behaviour when you use `facet_row` only, by disabling `matches` on the Y axes, or when using `facet_col` only, by disabling `matches` on the X axes. It is not recommended to use this approach when using `facet_row` and `facet_col` together, as in this case it becomes very hard to understand the labelling of axes and grid lines.
86+
87+
```python
88+
import plotly.express as px
89+
df = px.data.tips()
90+
fig = px.scatter(df, x="total_bill", y="tip", color='sex', facet_row="day")
91+
fig.update_yaxes(matches=None)
92+
fig.show()
93+
```
94+
95+
```python
96+
import plotly.express as px
97+
df = px.data.tips()
98+
fig = px.scatter(df, x="total_bill", y="tip", color='sex', facet_col="day")
99+
fig.update_xaxes(matches=None)
100+
fig.show()
101+
```
102+
103+
```python
104+
105+
```

0 commit comments

Comments
 (0)