title: Combine two complicated matplotlib.pyplot objects into subplots
body: <p>I have a function named <code>make_plot</code> that takes as an input a list of matrices of length 15 and outputs a plot that is a 3x5 collection of heatmaps (one for each of the matrices in the list).</p>
  <p>I would then like to display the output of this function applied to two different lists of matrices, showing the output side-by-side.</p>
  <p>I thought this was just a simple application of matplotlib subplots, as discussed here: <a href="https://matplotlib.org/stable/gallery/subplots_axes_and_figures/subplots_demo.html" rel="nofollow noreferrer">https://matplotlib.org/stable/gallery/subplots_axes_and_figures/subplots_demo.html</a></p>
  <p>However, I haven't figured out how to get the output of my custom function <code>make_plot</code> to fit into the subplots that I would like.</p>
  <p>For example, the provided code on the matplotlib site for how to make horizontal plots is</p>
  <pre><code>fig, (ax1, ax2) = plt.subplots(1, 2)
  fig.suptitle('Horizontally stacked subplots')
  ax1.plot(x, y)
  ax2.plot(x, -y)
  </code></pre>
  <p>But if I try a gentle modification like</p>
  <pre><code>fig, (ax1, ax2) = plt.subplots(1, 2)
  fig.suptitle('Horizontally stacked subplots')
  ax1 = make_plot(mats1)
  ax2 = mate_plot(mats2)
  </code></pre>
  <p>I get two empty plots, and then the usual outputs of <code>make_plot</code> stacked on top of each other.</p>
  <p>I feel like there is something I'm not really understanding about the nature of matplotlib objects, this seems like it should be a simple / reasonable thing to do, but I haven't figured out how to do it yet. Any pointers would be so appreciated!</p>