相关疑难解决方法(0)

Matplotlib:TypeError:'AxesSubplot'对象不可下标

我正在尝试对包含在两个数据帧df1和df2中的变量'x'进行简单的箱形图绘制。为此,我使用以下代码:

fig, axs = plt.subplots()
axs[0, 0].boxplot([df1['x'], df2['x']])
plt.show();
Run Code Online (Sandbox Code Playgroud)

但是,我得到这个:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-108-ce962754d553> in <module>()
----> 2 axs[0, 0].boxplot([df1['x'], df2['x']])
      3 plt.show();
      4 

TypeError: 'AxesSubplot' object is not subscriptable
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?

python matplotlib typeerror

5
推荐指数
1
解决办法
9936
查看次数

标签 统计

matplotlib ×1

python ×1

typeerror ×1