【问题标题】:Seaboron : subplot: TypeError: tuple indices must be integers or slices, not tupleSeaboron:子图:TypeError:元组索引必须是整数或切片,而不是元组
【发布时间】:2020-10-11 19:46:34
【问题描述】:

使用 seaborn countplot 和 subplot 时出现以下错误

TypeError:元组索引必须是整数或切片,而不是元组

【问题讨论】:

    标签: python-3.x seaborn subplot


    【解决方案1】:

    原因可能是返回时缺少 fig 变量。

    例如,取 Robbie here 提供的相同样本

    我的原因是我错过了在子图中使用“fig”变量返回,不知何故我无法重新创建场景。我在做如下

    ax =plt.subplots(1,2)
    

    当上面的语句被改写如下时,它就起作用了。

    fig, ax =plt.subplots(1,2)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-03-11
      • 2019-11-23
      • 2017-10-02
      • 2018-12-29
      • 2019-09-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多