0

The existing solution How do I change the figure size with subplots? does not answer my question.

fig, axs = plt.subplots(2, 2, figsize=(15, 15)) # Does not work in my case!

Other answers in my case of plotting two images with this code do not work also.

How can I resize a plot consisting of two side by side image subplots? I plot subplots in Jupyter notebook:

import matplotlib.pyplot as plt
import matplotlib.image as img

ref_img = img.imread(ref_img_path)
test_img = img.imread(test_img_path)

plt.subplot(1, 2, 1) # row 1, col 2 index 1
plt.title("Reference Form")
plt.imshow(ref_img)
plt.subplot(1, 2, 2) # index 2
plt.title("Test Form ")
plt.imshow(test_img)
plt.show()

I am not trying to create individual subplots of different size, but need to resize a plot as a whole to use maximum space in Jupyter cell.

dokondr
  • 3,389
  • 12
  • 38
  • 62
  • 1
    When your question is close as a duplicate, all answers in the linked duplicate are to be considered, not just the accepted answer. As such, this [answer](https://stackoverflow.com/a/66942163/7758804) and this [answer](https://stackoverflow.com/a/49100437/7758804). [plot and code](https://i.stack.imgur.com/8pCDQ.png). This question is a duplicate. – Trenton McKinney Mar 14 '23 at 18:33
  • And this [answer](https://stackoverflow.com/a/69476674/7758804) – Trenton McKinney Mar 14 '23 at 18:39
  • If you need different sized subplots, that is not clear from the question, which does not contain a complete [mre] with the relevant images. In any case, you would need to Use [GridSpec](https://matplotlib.org/stable/gallery/userdemo/demo_gridspec03.html#gridspec-demo), as shown in the 2nd duplicate. – Trenton McKinney Mar 14 '23 at 18:42
  • 1
    @Trenton McKinney, this works: https://stackoverflow.com/questions/14770735/how-do-i-change-the-figure-size-with-subplots/66942163#66942163 Thanks! – dokondr Mar 14 '23 at 18:49
  • You're welcome, that's what's shown in the first comment with the **plot and code** link. – Trenton McKinney Mar 14 '23 at 18:51

0 Answers0