<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"><style>body { line-height: 1.5; }p { margin-top: 0px; margin-bottom: 0px; }body { font-size: 10.5pt; font-family: 'Microsoft YaHei UI'; color: rgb(0, 0, 0); line-height: 1.5; }</style></head><body>
<div><span></span><table><tbody><tr><td class="votecell"><div class="vote"><div class="favoritecount"><b></b></div>
</div>
            </td>
            
<td class="postcell">
<div>
    <div class="post-text" itemprop="text">
<p>I am learing to use matplotlib to produce high quality picture for my paper. The demand dpi of this magzine is 300. </p>
<p>So, I wrote some example codes:</p>
<pre class="lang-py prettyprint prettyprinted" style="font-size: 15px;"><code><span class="kwd">import</span><span class="pln"> numpy </span><span class="kwd">as</span><span class="pln"> np
</span><span class="kwd">import</span><span class="pln"> matplotlib</span><span class="pun">.</span><span class="pln">pyplot </span><span class="kwd">as</span><span class="pln"> plt
a </span><span class="pun">=</span><span class="pln"> np</span><span class="pun">.</span><span class="pln">linspace</span><span class="pun">(</span><span class="lit">0</span><span class="pun">,</span><span class="pln"> </span><span class="lit">10</span><span class="pun">,</span><span class="pln"> </span><span class="lit">100</span><span class="pun">)</span><span class="pln">
b </span><span class="pun">=</span><span class="pln"> np</span><span class="pun">.</span><span class="pln">linspace</span><span class="pun">(</span><span class="lit">0</span><span class="pun">,</span><span class="pln"> </span><span class="lit">20</span><span class="pun">,</span><span class="pln"> </span><span class="lit">100</span><span class="pun">)</span><span class="pln">
plt</span><span class="pun">.</span><span class="pln">plot</span><span class="pun">(</span><span class="pln">a</span><span class="pun">,</span><span class="pln"> b</span><span class="pun">,</span><span class="pln"> </span><span class="str">'o'</span><span class="pun">)</span><span class="pln">
plt</span><span class="pun">.</span><span class="pln">xlabel</span><span class="pun">(</span><span class="pln">r</span><span class="str">'$x$'</span><span class="pun">)</span><span class="pln">
plt</span><span class="pun">.</span><span class="pln">ylabel</span><span class="pun">(</span><span class="pln">r</span><span class="str">'$y$'</span><span class="pun">)</span><span class="pln">
plt</span><span class="pun">.</span><span class="pln">grid</span><span class="pun">(</span><span class="kwd">True</span><span class="pun">)</span><span class="pln">
plt</span><span class="pun">.</span><span class="pln">savefig</span><span class="pun">(</span><span class="str">'fig1.jpg'</span><span class="pun">,</span><span class="pln"> dpi</span><span class="pun">=</span><span class="lit">300</span><span class="pun">,</span><span class="pln"> format</span><span class="pun">=</span><span class="str">'jpg'</span><span class="pun">)</span></code></pre>
<p>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.</p>
<p>Also I tried those:</p>
<pre class="lang-py prettyprint prettyprinted" style="font-size: 15px;"><code><span class="pln">matplotlib</span><span class="pun">.</span><span class="pln">rcParams</span><span class="pun">[</span><span class="str">'savefig.dpi'</span><span class="pun">]</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> </span><span class="lit">300</span></code></pre>
<p style="font-size: 15px;">or</p>
<pre class="lang-py prettyprint prettyprinted" style="font-size: 15px;"><code><span class="pln">plt</span><span class="pun">.</span><span class="pln">figure</span><span class="pun">(</span><span class="pln">dpi</span><span class="pun">=</span><span class="lit">300</span><span class="pun">)</span></code></pre>
<p style="font-size: 15px;">or</p>
<pre class="lang-py prettyprint prettyprinted" style="font-size: 15px;"><code><span class="str">'D:\Anaconda3\Lib\site-packages\matplotlib\mpl-data\matplotlibrc'</span><span class="pln"> </span></code></pre>
<p style="font-size: 15px;">in this file, make</p>
<pre class="lang-py prettyprint prettyprinted" style="font-size: 15px;"><code><span class="pln">savefig</span><span class="pun">.</span><span class="pln">dpi</span><span class="pun">=</span><span class="lit">300.</span><span class="pln"> </span></code></pre>
<p><strong>All of those is useless.</strong> </p>
<p>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!</p>
<p>My operating system is windows 10. Anaconda 3 helped me to install matplotlib module.</p>
<p><strong>Thank for your help!</strong></p></div></div></td></tr></tbody></table></div>
<div><br></div><hr style="width: 210px; height: 1px;" color="#b5c4df" size="1" align="left">
<div><span><div style="margin: 10px; font-size: 10pt;"><div style="font-size: 15px;"><font face="Times New Roman"><span style="line-height: 23.3125px;"><b>Weiwei Tan</b></span></font></div><div style="font-family: Arial; font-size: 15px; line-height: 23.8px;"><span style="line-height: 23.324px; font-family: 'Times New Roman';"><b>Institute of Heavy Ion Physics</b></span></div><div style="font-family: Arial; font-size: 14px; line-height: 23.8px;"><div style="font-family: 华文细黑; line-height: 23.324px;"><div style="font-family: 'Times New Roman'; font-size: 15px;"><b>School of Physics,Peking University </b></div></div></div></div></span></div>
</body></html>