Resize png image

Hello is there a way to resize the .png image using Plotly configuration or I need 3rd party package?
the command I use to save my plots is :

    fig.write_image("TankN.png", width=800, height=350, scale=2)

then I use docxtpl to generate rapports but the image is so big , and exceed to boundary of the page.

My Best.

Hi @smail,
You can fix this issue, setting some parameters in layout, as well as in

  • you can set image size in layout with:
fig.upate_layout(width=450, height=350, margin=dict(t=2, r=2,b=2, l=2)

margin with these settings reduces the white space around image.

  • you can resize your image, setting width and height in fig.write_image, too.
fig.write_image("my_image.png", width=400, height=300, scale=1)
1 Like