Add existing AxesSubplot object from visualize_image_attr_multiple

Kalle: <p>I followed a tutorial from <code>[blog.paperspace.com](https://blog.paperspace.com/model-interpretability-and-understanding-for-pytorch-using-captum/)</code> where I used Captum to visualize what my model learns. Until now it works great and I can get some visualization that makes sense.</p>
<p>However, I would love to add the output (<em>plt_fig, plt_axis</em>) of the following function to an existing subplot:</p>
<pre><code class="lang-auto">plt_fig, plt_axis = viz.visualize_image_attr_multiple(np.transpose(attributions_ig_nt.squeeze().cpu().detach().numpy(), (1,2,0)),
                                      np.transpose(transformed_img.squeeze().cpu().detach().numpy(), (1,2,0)),
                                      ["original_image", "heat_map"],
                                      ["all", "positive"],
                                      cmap=default_cmap,
                                      show_colorbar=True)
</code></pre>
<p>Currently the output of this function is the following image:</p>
<p><img src="https://discuss.pytorch.org/uploads/default/original/3X/a/1/a1f9b509651948b4abe2add0e04b44951e1d31c2.png" alt="cat" data-base62-sha1="n6TROc2yCr0lP4Hp1fTPj5tA1H4" width="602" height="312"></p>
<p>However, I would like to be able to add the subplot to an existing subplot, e.g:</p>
<p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/e/a/ea648b367a3939c9407d647f7004a641b45c94bb.png" data-download-href="https://discuss.pytorch.org/uploads/default/ea648b367a3939c9407d647f7004a641b45c94bb" title="multiple_cats"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/e/a/ea648b367a3939c9407d647f7004a641b45c94bb_2_690x377.png" alt="multiple_cats" data-base62-sha1="xrx8OydynFAObeQY8CKO7w65KNJ" width="690" height="377" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/e/a/ea648b367a3939c9407d647f7004a641b45c94bb_2_690x377.png, https://discuss.pytorch.org/uploads/default/optimized/3X/e/a/ea648b367a3939c9407d647f7004a641b45c94bb_2_1035x565.png 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/e/a/ea648b367a3939c9407d647f7004a641b45c94bb.png 2x" data-dominant-color="C6C3C0"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">multiple_cats</span><span class="informations">1139×623 335 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>
<p>Is this possible? I have tried multiple things, but none has worked until now. I am aware of that one solution is to change the source code, however, I am not very interested in that since I would like to keep the source code as it is.</p>
<p>Is there some other way? I even tried to save the image as png and then load it again, however, I dont like that solution <img src="https://discuss.pytorch.org/images/emoji/apple/slight_smile.png?v=12" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"></p>

Kalle: <p>The question is answered in the following:</p>
<aside class="onebox discoursetopic" data-onebox-src="https://discourse.matplotlib.org/t/add-existing-axessubplot-object-to-another-subplot/23518">
  <header class="source">
      <img src="https://discourse.matplotlib.org/uploads/default/optimized/1X/4e2601378070d95cf32bc89602ea07e641cd3006_2_32x32.png" class="site-icon" width="32" height="32">

      <a href="https://discourse.matplotlib.org/t/add-existing-axessubplot-object-to-another-subplot/23518" target="_blank" rel="noopener nofollow ugc" title="06:13AM - 31 January 2023">Matplotlib – 31 Jan 23</a>
  </header>

  <article class="onebox-body">
    <div class="aspect-image" style="--aspect-ratio:602/312;"><img src="https://discourse.matplotlib.org/uploads/default/original/2X/b/bd34af0bb57a7a17a5fd82cc4b611586743e9c98.png" class="thumbnail" width="602" height="312"></div>

<div class="title-wrapper">
  <h3><a href="https://discourse.matplotlib.org/t/add-existing-axessubplot-object-to-another-subplot/23518" target="_blank" rel="noopener nofollow ugc">Add existing AxesSubplot object to another Subplot</a></h3>
  <div class="topic-category">
      <span class="badge-wrapper bullet">
        <span class="badge-category-bg" style="background-color: #50A387;"></span>
        <span class="badge-category clear-badge">
          <span class="category-name">Community</span>
        </span>
      </span>
  </div>
</div>

  <p>I followed a tutorial from [blog.paperspace.com](https://blog.paperspace.com/model-interpretability-and-understanding-for-pytorch-using-captum/) where I used Captum to visualize what my model learns. Until now it works great and I can get some...</p>

  <p>
    <span class="label1">Reading time: 1 mins 🕑</span>
      <span class="label2">Likes: 1 ❤</span>
  </p>

  </article>

  <div class="onebox-metadata">
    
    
  </div>

  <div style="clear: both"></div>
</aside>