Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The first link in Google for <code>'matplotlib figure size'</code> is <a href="http://www.scipy.org/Cookbook/Matplotlib/AdjustingImageSize" rel="noreferrer">AdjustingImageSize</a> (<a href="https://webcache.googleusercontent.com/search?q=cache:5oqjjm8c8UMJ:https://scipy.github.io/old-wiki/pages/Cookbook/Matplotlib/AdjustingImageSize.html+&amp;cd=2&amp;hl=en&amp;ct=clnk&amp;gl=fr" rel="noreferrer">Google cache of the page</a>).</p> <p>Here's a test script from the above page. It creates <code>test[1-3].png</code> files of different sizes of the same image:</p> <pre><code>#!/usr/bin/env python """ This is a small demo file that helps teach how to adjust figure sizes for matplotlib """ import matplotlib print "using MPL version:", matplotlib.__version__ matplotlib.use("WXAgg") # do this before pylab so you don'tget the default back end. import pylab import numpy as np # Generate and plot some simple data: x = np.arange(0, 2*np.pi, 0.1) y = np.sin(x) pylab.plot(x,y) F = pylab.gcf() # Now check everything with the defaults: DPI = F.get_dpi() print "DPI:", DPI DefaultSize = F.get_size_inches() print "Default size in Inches", DefaultSize print "Which should result in a %i x %i Image"%(DPI*DefaultSize[0], DPI*DefaultSize[1]) # the default is 100dpi for savefig: F.savefig("test1.png") # this gives me a 797 x 566 pixel image, which is about 100 DPI # Now make the image twice as big, while keeping the fonts and all the # same size F.set_size_inches( (DefaultSize[0]*2, DefaultSize[1]*2) ) Size = F.get_size_inches() print "Size in Inches", Size F.savefig("test2.png") # this results in a 1595x1132 image # Now make the image twice as big, making all the fonts and lines # bigger too. F.set_size_inches( DefaultSize )# resetthe size Size = F.get_size_inches() print "Size in Inches", Size F.savefig("test3.png", dpi = (200)) # change the dpi # this also results in a 1595x1132 image, but the fonts are larger. </code></pre> <p>Output:</p> <pre><code>using MPL version: 0.98.1 DPI: 80 Default size in Inches [ 8. 6.] Which should result in a 640 x 480 Image Size in Inches [ 16. 12.] Size in Inches [ 16. 12.] </code></pre> <p>Two notes:</p> <ol> <li><p>The module comments and the actual output differ.</p></li> <li><p><a href="https://stackoverflow.com/questions/335896/how-to-complete-this-python-function-to-save-in-the-same-folder#336001">This answer</a> allows easily to combine all three images in one image file to see the difference in sizes.</p></li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload