How Can I Get All Plotly Plots Created Inside A For Loop Display In Single Browser Window?
I am trying to create several plots inside a for loop using plotly. Currently all the charts appear in separate tabs of browser. I want all the charts to appear in the same browser
Solution 1:
You could just move the point where you declare the figure outside of the loop and give it more rows or columns. For example, make a figure with as many columns as there are datapoints. Then put the plots in the ith column. Something like:
# use len(meas_set) as number of columns
fig = tools.make_subplots(rows=2, cols=len(meas_set), subplot_titles=('X-BAR Subplot','SIGMA Subplot'))
for i in meas_set:
for j in range(0,len(params)):
# your logic here
trace1 = go.Scatter(x=x_xbar,y=y_xbar,mode='lines',name=params[j])
trace2 = go.Scatter(x=x_sigma,y=y_sigma,mode='lines',name=params[j])
# use i for column position
fig.append_trace(trace1,1,i)
fig.append_trace(trace2,2,i)
Post a Comment for "How Can I Get All Plotly Plots Created Inside A For Loop Display In Single Browser Window?"