Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set dpi with plotly

Tags:

python

plotly

I know that savefig has an option dpi. but if I make plots with plotly and write image I don't have an option to set dpi.

How can I set dpi with plotly?

TypeError: write_image() got an unexpected keyword argument 'dpi'
like image 214
Noob Programmer Avatar asked Apr 19 '26 20:04

Noob Programmer


1 Answers

There is an option of passing scale argument to write_image method, which helps in increasing the resolution (by putting the value greater than 1) -- the same purpose intended by dpi.

So, the code would be like:

fig.write_image('figure.png', scale=2)

Here, the scale is put 2.

If the scale is less than 1, that would decrease the dimension instead.

like image 147
Suraj Regmi Avatar answered Apr 22 '26 08:04

Suraj Regmi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!