【发布时间】:2020-10-11 19:46:34
【问题描述】:
使用 seaborn countplot 和 subplot 时出现以下错误
TypeError:元组索引必须是整数或切片,而不是元组
【问题讨论】:
标签: python-3.x seaborn subplot
使用 seaborn countplot 和 subplot 时出现以下错误
TypeError:元组索引必须是整数或切片,而不是元组
【问题讨论】:
标签: python-3.x seaborn subplot
原因可能是返回时缺少 fig 变量。
例如,取 Robbie here 提供的相同样本
我的原因是我错过了在子图中使用“fig”变量返回,不知何故我无法重新创建场景。我在做如下
ax =plt.subplots(1,2)
当上面的语句被改写如下时,它就起作用了。
fig, ax =plt.subplots(1,2)
【讨论】: