Black Lives Matter. Please consider donating to Black Girls Code today.
Dash Enterprise delivers an incredible 21x cost savings 💸Download the e-book!

Plotly subplots using fig objects instead of traces


I have two plotly figures, one with two traces on a time series, and the other one is a scatter plot.

If I want to put them side by side, can I use subplots to do it? But I use the actual figure objects, not the individual traces.

Hey @dfernan

Have you seen Plotly’s subplot docs


Yes, it’s at the trace level, but no subplots can be done at the figure level.

I think generally it’s better to have better compartmentalization between the different figures. I’d want to create each figure separately, specially when working with very different figure types, each with it’s own complexities (legends, primary and secondary axis, etc.) and then the subplot by figure would be as easy as subfigs([fig1, fig2, fig3, fig4], rows=2, cols=2) or something like that. This would also allow for their own layouts, titles, etc. I think it has some advantages to it.

These are just suggestions, not sure how to do this yet.

I found this on the community forum so i guess it’s not really doable yet:

With Plotly 3.0.0+ you can create what you call subplots of figures. Namely, you define the figures as instances of go.FigureWidget().
If you have two such figures, fw1, fw2, define

fig_subplots=  HBox([fw1, fw2])
fig_subplots #this line displays the subplots in the Jupyter Notebook

To set the horizontal space between figures just update their margins:

fw1.layout.update(margin=dict( r=20))
fw2.layout.update(margin=dict( l=30))

If you have 3 or more figures you can locate them by a combination of VBox and HBox, imported from ipywidgets:

dashboard1=VBox([HBox([fw1, fw2]), HBox([fw3])])


this is great, just updated my plotly version, important changes.

Hi I read through this post as I am trying to follow how to show multiple figures (“figs”). I am trying to show my multiple figs in a webpage via cmd.

I can “” the individuals figs…

but then I try:

import plotly
import plotly.graph_objs as go
import ipywidgets as ipw
fig_subplots - ipw.HBox([fig1, fig2])

I get an error that says:

AttributeError: ‘HBox’ object has no attribute ‘show’

how can I show the HBox in the webpage?

Can anyone help?



Unfortunately, figurewidgets can be displayed only in a Jupyter Notebook…

thank you very much for getting back to me. Is there another way with any Plotly tool to show multiple charts and tables in a webpage that you know of? Thank you very much again

Try Dash! You can put each graph object in its own HTML element.

How to use categorical column in color in plotly graph objects ?