在同一笔记本单元格中显示多个图

Display Multiple Figures in Same Notebook Cell

我有几个列表中的数据示例。

data1 = [91.0, 199.0, 298.0, 271.0, 129.0, 320.0, 104.0, 177.0, 236.0, 89.0, 229.0, 274.0, 239.0,
246.0, 91.0, 199.0, 298.0, 271.0, 129.0, 320.0, 104.0, 177.0, 236.0, 89.0, 229.0, 274.0, 239.0,
246.0]
data2 = [1,5,7,12,5,9,7,2,2,3,15,17,11,5,8,3,1,5,1]
...

在一个单元格中,我想显示每个数据集的直方图。我试过这个:

fig, axs = plt.subplots(1,2)
hist1 = plt.hist(data1, label='First graph').plot(ax=axs[0])

但是我得到一个错误

另外,如果我这样做:

plt.hist(data1)
plt.hist(data2)

它只显示第一个

这是我从评论中得出的结论

fig, axs = plt.subplots(1,2)
axs[0].hist(data1)
axs[1].hist(data2)
...