Hello, I encountered a similar problem before, here was how I roughly achieve this:
Create a parent div to hold all the graphs (like all the lines of graphs).
Write a for loop that starts with i = 0, i += 1 each iteration, for each iteration do:
** if i % 2 == 0, then append an empty row to the Div, append a column width 6 containing the next graph into that new row, then next.
** if i % 2 == 1, then only append the next graph within a column width 6 into the latest row.
** if i == number of graphs, break the loop.
An alternative would be to use Plotly’s subplots feature (https://plot.ly/python/subplots/). Dash would then see this as one ‘figure’ object. You would, of course, have to adapt your myPlot function and callback to reflect those changes.
Hi @dnaiel , my solution was to have the callback function return a Div in which children are rows, each row contains 2 graphs.
So technically, if my list have 9 graphs, then my solution would be to return a Div with 5 rows in it, each row has 2 graphs in 2 columns of width 6, except for the last one which has only 1 graph. @mikesmith1611 suggested using subplots by Plotly, which I think would be much easier than my solution. Admittedly when I started out with Dash I didn’t know fully all the features of plotly so glad to see that they have subplots. In that case, the list of graphs would be one graph with n subplots.
one reason you may prefer multiple plots to a subplot is the ease with which you can save individual graphs
i have found trying to save 5 rows of graphs to an offline png you lose all the height dimensions set in plotly