matplotlib - change figsize but keep fontsize constant
<p>I want to display several figures with different sizes, making sure that the text has always the same size when the figures are printed. How can I achieve that?</p>

<p>As an example. Let's say I have two figures:</p>

<pre><code>import matplotlib.pylab as plt
import matplotlib as mpl

mpl.rc('font', size=10)

fig1 = plt.figure(figsize = (3,1))
plt.title('This is fig1')
plt.plot(range(0,10),range(0,10))
plt.show()


mpl.rc('font', size=?)

fig2 = plt.figure(figsize = (20,10))
plt.title('This is fig2')
plt.plot(range(0,10),range(0,10))
plt.show()
</code></pre>

<p>How can I set the fontsize in such way that when printed the title and axis ticklabels in fig1 will have the same size as those in fig2?</p>

<p>In this case, the font size would be the same (i.e. also 10 points). </p>

<p>However, in Jupyter Notebook the figures may be displayed at a different size if they are too wide, see below: </p>

<p><a href="http://i.stack.imgur.com/zBGLp.png" rel="nofollow"><img src="http://i.stack.imgur.com/zBGLp.png" alt="Jupyter Notebook example"></a></p>

<p>Note that font size in points has a linear scale, so if you would want the size of the letters to be exactly twice as big, you would need to enter exactly twice the size in points (e.g. 20pt). That way, if you expect to print the second figure at 50% of the original size (length and width, not area), the fonts would be the same size. </p>

<p>But if the only purpose of this script is to make figures to then print, you would do best to set the size as desired (on paper or on screen), and then make the font size equal. You could then paste them in a document at that exact size or ratio and the fonts would indeed be the same size. </p>

<hr>

<p>As noted by <a href="http://stackoverflow.com/users/380231/tcaswell">tcaswell</a>, <code>bbox_inches='tight'</code> effectively changes the size of the saved figure, so that the size is different from what you set as <code>figsize</code>. As this might crop more whitespaces from some figures than others, the relative sizes of objects and fonts could end up being different for a given aspect ratio. </p>

python matplotlib figure