figuresize and dpi

Chaitanya Krishna <icymist@...287...> writes:

I define the figure size as fig = plt.figure(figsize=(7,0.75*7)), then
plot the figure and save it as both a png and an eps.

When you save as png, you can set the dpi, and if you use e.g. 100, the
figure will be 700 pixels wide; if you use 75, it will be 525 pixels
wide. The dpi is saved in the png file, so the viewer application can in
principle know how to rescale it.

When you save as eps, which is a vector graphics format, the dpi
argument will not have much effect (with the exception of resampled
images). It is up to the viewer application to show it at the correct
size. When you print the file, it should appear at the right size,
although it is not impossible for there to be some measurable error.
Presumably a professional publisher will make sure that their printing
equipment comes as close as possible to the intended size.

If I then measure the size of the figure as displayed (displayed with
0 zoom) on the computer screen with a ruler, it does not measure 7 in.
Why is it so? Am I doing something wrong.

Often, the viewer application does not know what the dpi value of the
screen is - popular guesses are 75 and 100, but this naturally depends
on the physical size of the screen. For example, a resolution of 1280 x
1024 at 15 inches or 17 inches will have a different dpi, and if the
viewer application (or the operating system, or the windowing system)
just has some default guess, you will not see the correct size on the

I think The GIMP has a dpi calibration dialog where it shows rulers and
asks you to measure them with a physical ruler. You might want to
install The GIMP, set up the dpi and use it to view your png files.


Jouni K. Sepp�nen