I'm trying to display two images side by side in scale. This is the code:
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(10, 15))
ax1.imshow(bird_rescaled)
ax2.imshow(bird_resized)
Unfortunately I just managed to come to this result:
.
What I'd like to have is two in-scale images side by side, kind of like this:
Is there some function argument I'm missing that could solve this?
As mentioned by @mozway , sharey=True
helped solving this problem.
I modified the code in this way:
fig, (ax1, ax2) = plt.subplots(1, 2, sharey=True, sharex=True, figsize=(12, 6))
ax1.imshow(bird_rescaled)
ax2.imshow(bird_resized)
adding sharex=True
so that now the result looks perfect. [I can't post images because I don't have at least 10 reputation:(]
I also changed the values passed to the figsize
argument:
I wanted the images to be 6x6 so the total figure needed to be 12x6.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.