I am learing to use matplotlib to produce high quality picture for my paper. The demand dpi of this magzine is 300.
So, I wrote some example codes:
import numpy as np
import matplotlib.pyplot as plt
a = np.linspace(0, 10, 100)
b = np.linspace(0, 20, 100)
plt.plot(a, b, 'o')
plt.xlabel(r'$x$')
plt.ylabel(r'$y$')
plt.grid(True)
plt.savefig('fig1.jpg', dpi=300, format='jpg')
But I got a picure whose dpi is 72, and its size is 2400*1800. I'm confused about this outcome. I searched the Internet and some references about dpi setting, but I can't solve this problem anyway.
Also I tried those:
matplotlib.rcParams['savefig.dpi'] = 300
or
plt.figure(dpi=300)
or
'D:\Anaconda3\Lib\site-packages\matplotlib\mpl-data\matplotlibrc'
in this file, make
savefig.dpi=300.
All of those is useless.
I think the reason why the size of produced figure is 2400*1800. Because (300dpi*8 inches)*(300dpi*6 inches). The default size of figure in rc file is 8 inches and 6 inches. But why the dpi of this figure can't be changed!
My operating system is windows 10. Anaconda 3 helped me to install matplotlib module.
Thank for your help!

How are you determining that the figure dpi is still 72?

Tom

ps please subscribe to the mailing list so you can post with out moderation
intervention.

ยทยทยท

On Mon, May 16, 2016 at 1:53 PM tanweiwei at pku.edu.cn <tanweiwei at pku.edu.cn> wrote:

I am learing to use matplotlib to produce high quality picture for my
paper. The demand dpi of this magzine is 300.

So, I wrote some example codes:

import numpy as npimport matplotlib.pyplot as plt
a = np.linspace(0, 10, 100)
b = np.linspace(0, 20, 100)
plt.plot(a, b, 'o')
plt.xlabel(r'$x$')
plt.ylabel(r'$y$')
plt.grid(True)
plt.savefig('fig1.jpg', dpi=300, format='jpg')

But I got a picure whose dpi is 72, and its size is 2400*1800. I'm
confused about this outcome. I searched the Internet and some references
about dpi setting, but I can't solve this problem anyway.

I think the reason why the size of produced figure is 2400*1800. Because
(300dpi*8 inches)*(300dpi*6 inches). The default size of figure in rc file
is 8 inches and 6 inches. But why the dpi of this figure can't be changed!

My operating system is windows 10. Anaconda 3 helped me to install
matplotlib module.

*Thank for your help!*

------------------------------
*Weiwei Tan*
*Institute of Heavy Ion Physics*
*School of ?Physics?Peking University *
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users at python.org https://mail.python.org/mailman/listinfo/matplotlib-users