Write_image y-axis titles within plot

Iโ€™m developing a streamlit app containing plotly charts. Iโ€™m exporting images of the charts to insert them in dynamically generated powerpoint slides.

When I export images of figures using write_image, y-axis titles are pushed within the plot itself.
This means that for some figures, the titles are on top of lines, bars or whatever.

How can I avoid this? In below example, the figure is a combined bar and line chart.

Hereโ€™s my code:


Example of exported image using write_image with multiple plots and two y-axis (stacked bar chart and line chart):
image

Oh snap. I figured it out. This is caused by setting custom margin with fig.update_layout. If margin is set to 0 for left and right, the y-axis title(s) is pushed within the plot.

E.g.


Should be corrected to:

Will leave this here for others.

1 Like