# Add existing AxesSubplot object from visualize\_image\_attr\_multiple

**URL:** <https://discuss.pytorch.org/t/add-existing-axessubplot-object-from-visualize-image-attr-multiple/171367>\
**Category:** Captum\
**Created:** [January 30, 2023, 11:17am UTC](https://discuss.pytorch.org/t/add-existing-axessubplot-object-from-visualize-image-attr-multiple/171367 "2023-01-30T11:17:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kalle](https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/k/aeb1de/32.png) [@Kalle](https://discuss.pytorch.org/u/Kalle)\
**Post date:** [January 30, 2023, 11:17am UTC](https://discuss.pytorch.org/t/add-existing-axessubplot-object-from-visualize-image-attr-multiple/171367/1 "2023-01-30T11:17:13Z")

</div>

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 visualization that makes sense.

However, I would love to add the output (_plt\_fig, plt\_axis_) of the following function to an existing subplot:

```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)

```

Currently the output of this function is the following image:

![cat](https://discuss.pytorch.org/uploads/default/original/3X/a/1/a1f9b509651948b4abe2add0e04b44951e1d31c2.png)

However, I would like to be able to add the subplot to an existing subplot, e.g:

 ![multiple_cats](https://discuss.pytorch.org/uploads/default/original/3X/e/a/ea648b367a3939c9407d647f7004a641b45c94bb.png)

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.

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 🙂

---

<div class="post-metadata">

**Author:** ![Kalle](https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/k/aeb1de/32.png) [@Kalle](https://discuss.pytorch.org/u/Kalle)\
**Post date:** [February 2, 2023, 1:10pm UTC](https://discuss.pytorch.org/t/add-existing-axessubplot-object-from-visualize-image-attr-multiple/171367/2 "2023-02-02T13:10:45Z")

</div>

The question is answered in the following:

> **[Add existing AxesSubplot object to another Subplot](https://discourse.matplotlib.org/t/add-existing-axessubplot-object-to-another-subplot/23518)**
>
> 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...
