'How to create a plotly figure factory subplots in python?
Sample data
import seaborn as sns
sample = sns.load_dataset("tips")
Figure Factory plot
import plotly.figure_factory as ff
fig = ff.create_table(sample.head())
fig.show()
I wanted to plot a sample.head() and sample.tail() side by side as a subplots with create_table()
How to plot subplots with ff.create_table() in plotly?
Solution 1:[1]
I'd recommend using https://plotly.com/python/table/ and https://plotly.com/python/subplots/
Using sample data:
import seaborn as sns
import plotly.figure_factory as ff
import plotly.graph_objects as go
from plotly.subplots import make_subplots
sample = sns.load_dataset("tips")
fig = make_subplots(
rows=1,
cols=2,
specs=[[{"type": "table"} for _ in range(2)]],
)
fig.add_trace(
go.Table(
cells={"values": sample.head().values.T}, header={"values": sample.columns}
),
row=1,
col=1,
)
fig.add_trace(
go.Table(
cells={"values": sample.tail().values.T}, header={"values": sample.columns}
),
row=1,
col=2,
)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Rob Raymond |


