1

I have 7 images that I need to show in a single matplotlib figure. But there are remaining a lot of whitespace after adding the images. I tried following the second answer of this question: How do I change the figure size with subplots? but it did not work Here are my code and the output 'images' is the list of PIL images stored

fig=plt.figure(figsize=(40,20))
rows=4
columns = 2
for i in range(1,7,1):
      subim = fig.add_subplot(rows, columns, i)
      subim.imshow(images[i-1])

output: I want the small images to extend and fit the width of the plot enter image description here

suman
  • 57
  • 8
  • 2
    You need more columns. The whitespace comes from the images keeping their original aspect ratio. What about 2 rows and 4 columns? Or 1 row and 7 columns? If you really want to deform the images, you can use `imshow(..., aspect='auto')`. You can also change the figsize to make enough room in the height. – JohanC Mar 09 '21 at 11:43
  • ok thanks, it worked – suman Mar 10 '21 at 04:26

0 Answers0