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'
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'
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.
As Suraj Regmi already wrote, use the scale
parameter:
In doing so, you will not violate the sizes of fonts and lines.
To understand what parameter you need keep in mind that with scale
= 1 the image will be 700x500
pixels in size.
Thus, if you want an 130 mm image with a 300 dpi resolution, then
scale = (width_in_mm / 25.4) / (width_default_px / dpi) = (130 / 25.4) / (700 / 300) = 2.1934758155230596
or
scale = width_in_mm * 17780.0 # dpi=300