Subplots size/tick spacing pyplot
<p>I have searched for similar problems and not found any, so I apologize.</p>

<p>I have this:</p>

<pre><code>import matplotlib.pyplot as plt

yearlymean_gm = np.load('ts_globalmean_annualmean.npz')
ts = yearlymean_gm['ts_aqct']

time = np.arange(0., 45 , 1)
plt.figure( figsize=(12, 5), dpi=80, facecolor='w', edgecolor='k' )

ax = plt.subplot(3, 4, 1)

data = ts[0, :]
plt.plot(time, data)
plt.title('Annual Mean Global Mean Temperature', fontsize=14)
plt.xlabel('year', fontsize=12)
plt.ylabel(modnames[0], fontsize=12)
plt.xlim(0, 50), plt.ylim(275, 310)
ax.set_xticks(time)
ax.set_xticklabels(time, fontsize = 8)

ax= plt.subplot(3, 4, 2)

data = ts[1, :]
plt.plot(time, data)
plt.title('Annual Mean Global Mean Temperature', fontsize=14)
plt.xlabel('year', fontsize=12)
plt.ylabel(modnames[1], fontsize=12)
plt.xlim(0, 50), plt.ylim(275, 310)
ax.set_xticks(time)


ax = plt.subplot(3, 4, 3)

data = ts[2, :]
plt.plot(time, data)
plt.title('Annual Mean Global Mean Temperature', fontsize=14)
plt.xlabel('year', fontsize=12)
plt.ylabel(modnames[2], fontsize=12)
plt.xlim(0, 50), plt.ylim(275, 310)
ax.set_xticks(time)


plt.tight_layout()
plt.show()
plt.close
</code></pre>

<p>There are currently 9 missing plots, as I'm sure you could guess, <a href="http://i.stack.imgur.com/Q07Fc.jpg" rel="nofollow"><img src="http://i.stack.imgur.com/Q07Fc.jpg" alt="Here&#39;s what it&#39;s spitting out right now"></a></p>

<p>Here are the three issues, to be clear:
1) Each subplot is <em>tiny</em> compared to the size of the figure (and, you know... what's easily visible). Reducing the size of the figure doesn't make the subplots any more easily readable.</p>

<p>2) They are too close together. I have some ideas about how to solve this, but I feel like I need to resolve 1) first.</p>

<p>3) The axes are so small that the xticks appear all bunched up</p>

<p>I've searched and found no explanation as to how to do this that's written at a level I can understand. The pyplot documentation is essentially gibberish to me.</p>

<p>Thanks in advance for any assistance (and if anyone can offer more general advice about what I'm doing in addition to specific advice about solving this problem, I would appreciate the edification).</p>

<p>Ok, so several things are happening here.  Let got through them one at a time.  After you instantiate the plot, you call <code>ax = plt.subplot(3, 4, _)</code> 3 times.  However, <code>.subplot(3,4,_)</code> breaks the plot into 3 rows and 4 columns and the underscore selects which piece of this grid to select starting with 1 (instead of 0).  We can number them with the following code:</p>

<pre><code>plt.figure( figsize=(12, 5), dpi=80, facecolor='w', edgecolor='k' )
for N in range(1,13):
    ax = plt.subplot(3, 4, N)
    ax.annotate(s=str(N), xy=(.4,.4), fontsize=16)
</code></pre>

<p><a href="http://i.stack.imgur.com/5ixzD.png" rel="nofollow"><img src="http://i.stack.imgur.com/5ixzD.png" alt="enter image description here"></a></p>

<p>So but using <code>.subplot(3,4,1)</code>, <code>.subplot(3,4,2)</code>, and <code>.subplot(3,4,3)</code> you are only selecting the first 3 of the 12 sections.  </p>

<p>When you add the data to the plot, <code>ax.set_xticks(time)</code> adds 45 ticks to the xaxis (which is quite a few), and <code>ax.set_xticklabels(time, fontsize = 8)</code> adds a label at each tick.  This is why it looks so crowded.  One options is to reduce the number of ticks, the other is to stretch the x-axis out.  Since you have 3 subplots, I think you wanted to 3 rows stacked vertically.</p>

<p>You don't need <code>plt.xlim(0, 50)</code> or  <code>plt.ylim(275, 310)</code>.  The axis will resize the plot limits for you, unless you have a specific reason for overriding them. </p>

<p>My recommendation would be to use <code>plt.subplots(3,1)</code> (notice the extra "s") rather than repeated calls to <code>plt.subplot</code>.  What the difference?  <code>plt.subplots(3,1)</code> returns a tuple of a <code>figure</code> object and an array of <code>axis</code> objects.  In this case it is a 1-D array because we only call for 1 column.  (NOTE: I created fake data for illustrative purposes.) </p>

<pre><code>fig, axes = plt.subplots(3,1, figsize=(12,5), dpi=80, facecolor='w',
                         edgecolor='k', sharex=True)  # sharex shares the x-axis

for i, ax in enumerate(axes):  # need to enumerate to slice the data
    data = ts[i, :]
    ax.plot(time, data)
    ax.set_ylabel(modnames[i], fontsize=12)
    ax.set_xticks(time)
    ax.set_xticklabels(time, fontsize = 8)

# set xlabel outside of for loop so only the last axis get an xlabel
ax.set_xlabel('year', fontsize=12)
fig.tight_layout()

# set the title, adjust the spacing
fig.suptitle('Annual Mean Global Mean Temperature', fontsize=14)
fig.subplots_adjust(top=0.90)
</code></pre>

<p><a href="http://i.stack.imgur.com/nczqK.png" rel="nofollow"><img src="http://i.stack.imgur.com/nczqK.png" alt="enter image description here"></a></p>

python matplotlib subplot