在 jupyter notebook 单元格上绘制两个图时出现 AttributeError

AttributeError while doing two plots on a jupyther notebook cell

我在用seaborn和matplotlib画图,一个是箱线图:

ax = sns.boxplot(x=data["MEDV"])

另一个是直方图,我改变了轴的比例:

g = sns.distplot(data['MEDV'])  
plt.ticklabel_format(style='sci', axis='both', scilimits=(0,0))

如果我在不同的单元格上制作这两个图都很好,但如果我使用相同的单元格:

ax = sns.boxplot(x=data["MEDV"])

g = sns.distplot(data['MEDV'])  
plt.ticklabel_format(style='sci', axis='both', scilimits=(0,0))

我收到以下错误:

AttributeError: This method only works with the ScalarFormatter.

如果您想要两个子图,每个子图都包含其中一个图:

fig, (ax, ax2) = plt.subplots(ncols=2)
sns.boxplot(x=data, ax=ax)

sns.distplot(data, ax=ax2)  
plt.ticklabel_format(style='sci', axis='both', scilimits=(0,0))

如果你想要两个不同的数字,每个图一个:

plt.figure()
sns.boxplot(x=data)

plt.figure()
sns.distplot(data)  
plt.ticklabel_format(style='sci', axis='both', scilimits=(0,0))