Python 使用seaborn'从熊猫数据库制作多个绘图;使用“色调”选项绘制小提琴图

Python 使用seaborn'从熊猫数据库制作多个绘图;使用“色调”选项绘制小提琴图,python,pandas,matplotlib,anaconda,seaborn,Python,Pandas,Matplotlib,Anaconda,Seaborn,我正在与a()合作,试图学习更多关于如何可视化数据和一些机器学习的基础知识,我似乎真的被卡住了。我正在尝试使用seaborn小提琴图,使用色调标签在数据集中按列绘制红葡萄酒和白葡萄酒,而不是按质量列 我可能没解释清楚 无论如何,我的代码如下所示: class Wine(): def __init__(self): self.Process() def Process(self): whit = pds.read_csv("winequality-white.csv

我正在与a()合作,试图学习更多关于如何可视化数据和一些机器学习的基础知识,我似乎真的被卡住了。我正在尝试使用seaborn小提琴图,使用色调标签在数据集中按列绘制红葡萄酒和白葡萄酒,而不是按质量列

我可能没解释清楚

无论如何,我的代码如下所示:

class Wine():
  def __init__(self):
    self.Process()

  def Process(self):
    whit    = pds.read_csv("winequality-white.csv", sep=";", header=0)
    reds    = pds.read_csv("winequality-red.csv", sep=";", header=0)
    self.Plot_Against_Color(whit, reds)

  def Plot_Against_Color(self, white, red):
    nwhites = white.shape[0]; nreds   = red.shape[0]
    white_c = ["white"] * nwhites; red_c   = ["red"]   * nreds
    white['color'] = white_c; red['color'] = red_c
    total = white.append(red, ignore_index=True)

    parameters = list(total)
    nparameters = len(parameters)
    plt_rows = math.floor((nparameters - 1) / 3)
    if (nparameters - 1) % 3 > 0:
      plt_rows += 1
    fig, ax = plt.subplots(int(plt_rows), 3)
    fig.suptitle('Characteristics of Red and White Wine as a Function of Quality')
    for i in range(len(parameters)):
      title = parameters[i]
      if title == 'quality' or title == 'color':
        continue
      print(title)
      r = math.floor(i / 3);
      c = i % 3
      sns.violinplot(data=total, x='quality', y=title, hue='color', split=True, ax=[r, c])
      ax[r, c].set_xlabel('quality')
      ax[r, c].set_ylabel(title)
    plt.tight_layout()
这给了我一个错误

  AttributeError: 'list' object has no attribute 'fill_betweenx'
我也试着用这个例子把它写到子包中


这是另外一系列错误。我现在不知道该怎么办。。。有什么帮助吗?

问题出在这部分:

  sns.violinplot(data=total, x='quality', y=title, hue='color', split=True, ax=[r, c])
请按如下方式更正轴分配ax=ax[r,c]:

  sns.violinplot(data=total, x='quality', y=title, hue='color', split=True, ax=ax[r, c])

所有这些都应该可以正常工作。

您没有向我们展示您的全部代码。调用
fill\u betweenx
的位置在哪里?工作得很好!你不知道这救了我的头痛,谢谢。