This was previously asked in the year 2005: Link-1 and Link-2
Still remains unfixed / unanswered.
Why does the SVG renderer set a fixed DPI of 72?
As far as I know, SVG is DPI-independent.
The reason I brought this up is because the SVG document dimensions end up as 460.8 points x 345.6 points by default. (DPI = 72)
A PNG image on the other hand would be saved with the dimensions 640 pixels x 480 pixels by default. (DPI = 100)
Is there a particular reason for this. Shouldn’t both be similar?
In backend_svg.py, you will find the following line:
fixed_dpi = 72
as well as the following lines:
dpi = self.figure.dpi
self.figure.dpi = 72
width, height = self.figure.get_size_inches()
w, h = width * 72, height * 72
It seems to be overridden. Is this intentional?
Setting the dpi parameter in savefig when exporting to SVG has no effect. (it’s basically ignored)
Instead, I see 12 counts of the magic number 72 used within the backend_svg.py file.
Replacing all counts of 72 with 100 results in an SVG file with width = 640, height = 480, and viewbox = 0 0 640 480, up from the otherwise default/fixed width = 460.0, height = 345.6, and viewbox = 0 0 460.0 345.6.