Skip to content

Latest commit

 

History

History
69 lines (60 loc) · 1.93 KB

File metadata and controls

69 lines (60 loc) · 1.93 KB
jupyter
jupytext kernelspec language_info plotly
notebook_metadata_filter text_representation
all
extension format_name format_version jupytext_version
.md
markdown
1.1
1.1.1
display_name language name
Python 3
python
python3
codemirror_mode file_extension mimetype name nbconvert_exporter pygments_lexer version
name version
ipython
3
.py
text/x-python
python
python
ipython3
3.6.7
description display_as language layout name order page_type permalink redirect_from thumbnail
How to make Facet and Trellis Plots in Python with Plotly.
statistical
python
base
Facet and Trellis Plots
8
u-guide
python/facet-plots/
python/trellis-plots/
thumbnail/facet-trellis-thumbnail.jpg

Facet and Trellis Plots

Facet plots, also known as trellis plots or small multiples, are figures made up of multiple subplots which have the same set of axes, where each subplot shows a subset of the data. While it is straightforward to use plotly's subplot capabilities to make such figures, it's far easier to use the built-in facet_row and facet_col arguments in the various Plotly Express functions.

Scatter Plot Column Facets

import plotly.express as px
tips = px.data.tips()
fig = px.scatter(tips, x="total_bill", y="tip", color="smoker", facet_col="sex")
fig.show()

Bar Chart Row Facets

import plotly.express as px
tips = px.data.tips()
fig = px.bar(tips, x="size", y="total_bill", color="sex", facet_row="smoker")
fig.show()

Histogram Facet Grids

import plotly.express as px
tips = px.data.tips()
fig = px.histogram(tips, x="total_bill", y="tip", color="sex", facet_row="time", facet_col="day",
       category_orders={"day": ["Thur", "Fri", "Sat", "Sun"], "time": ["Lunch", "Dinner"]})
fig.show()