I want to create 20 subplots histogram charts with ploty but the size of the overall plot is not optimal:
from plotly.subplots import make_subplots
import plotly.graph_objs as go
data = [some data]
fig = make_subplots(rows=len(data), cols=1, shared_xaxes=True,
vertical_spacing=0.02, row_heights=[50] * 20)
p = 1
for i in data:
fig.append_trace(go.Histogram(x=i), row=p, col=1)
p += 1
fig.show()
The plot looks like this:
I would like to have some more space between the plots and increase the height of the subplots. I tried to play with the vertical_spacing and row_heights parameters but the plots are not updating.
How can I increase the height of the subplots and the space between them?
Agree with @r-beginners, you'll have to play with the size options to get the plots to look right. There are two ways I've used before, setting the size in fig.update_layout()
or when exporting the image in fig.write_image()
.
updating image:
fig.update_layout(
autosize=False,
width=1920,
height=2000)
exporting image:
fig.write_image('histograms.pdf',
width=1920,
height=2000)