Skip to content

Commit d39828e

Browse files
emmanuellenicolaskruchten
authored andcommitted
added example about facet_col_wrap, and one example for disabling axis sharing
1 parent 878d394 commit d39828e

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

python/facet-plots.md

Lines changed: 30 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.7.3
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,20 @@ 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 as follows.
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',
91+
facet_row="day", facet_col='time')
92+
# No match between subplot axes
93+
fig.update_xaxes(matches=None)
94+
fig.update_yaxes(matches=None)
95+
# Show ticks for each axis since they are now independent
96+
fig.update_xaxes(showticklabels=True)
97+
fig.show()
98+
```

0 commit comments

Comments
 (0)