Issue
If I have multiple plotly figures within Spyder IDE how can I display them all on one browser window?
E.g. if I run the below code it opens two charts on two separate windows, whereas I want them on one page, one after the other:
fig = px.scatter(x=[0, 1, 2, 3, 4], y=[0, 1, 4, 9, 16])
fig_1 = px.scatter(x=[0, 1, 2, 3, 4], y=[0, 2, 5, 7, 9])
plot(fig)
plot(fig_1)
Solution
You could use make_subplots
:
from plotly.subplots import make_subplots
import plotly.graph_objects as go
fig = make_subplots(rows=2, cols=1)
fig.append_trace(
go.Scatter(
x=[0, 1, 2, 3, 4],
y=[0, 1, 4, 9, 16],
),
row=1,
col=1,
)
fig.append_trace(
go.Scatter(
x=[0, 1, 2, 3, 4],
y=[0, 2, 5, 7, 9],
),
row=2,
col=1,
)
fig.show()
Alternatively you could use plotly dash to create more complex layouts and dashboards.
Answered By - Bas van der Linden
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.