简体   繁体   中英

How to show two pictures in one cell in Jupyter Notebook? (matplotlib) (python)

咖啡

马

As a beginner, can someone please help me with this? Is there any way to show both pictures in a single cell's output? My output could only display one picture. Thank you for your time and attention!

Here is my code:

from skimage import data
image_coffee = data.coffee()
image_horse = data.horse()
fig = plt.figure(dpi=100)
plt.imshow(image_coffee)
plt.imshow(image_horse)

You can use plt.subplots :

from skimage import data
import matplotlib.pyplot as plt
image_coffee = data.coffee()
image_horse = data.horse()
fig,ax = plt.subplots(ncols=2,nrows=1)
ax[0].imshow(image_coffee)
ax[2].imshow(image_horse)

在此处输入图像描述

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM