Place two plotly generated tables adjacent to each other

Viewed 345

I have created two Plotly tables that are of different dimensions and want to place them beside each other. Is there a way to perform this task without the implementation of dash?

1 Answers

Yes, you can make the tables subplots of type table:

import plotly.graph_objects as go
from plotly.subplots import make_subplots

fig = make_subplots(rows=1, cols=2, specs=[[{"type": "table"}, {"type": "table"}]])

fig.add_trace(
    go.Table(
        header=dict(values=["A", "B"]),
        cells=dict(values=[[1, 2, 3, 4], [2, 4, 6, 8]]),
    ),
    row=1,
    col=1,
)
fig.add_trace(
    go.Table(
        header=dict(values=["C", "D", "E"]),
        cells=dict(values=[[3, 6, 9, 12, 15], [4, 8, 12, 16, 20], [5, 10, 15, 20, 25]]),
    ),
    row=1,
    col=2,
)
fig.show()

tables

Related