【发布时间】:2022-01-03 07:50:11
【问题描述】:
谁知道为什么拆分的部分没有加入?enter image description here
sns.violinplot(x = "good", y = "fixed acidity", hue = "good", data = df,\ palette="muted", split=True, inner = "quartile", bw=.2)
【问题讨论】:
标签: split violin-plot
谁知道为什么拆分的部分没有加入?enter image description here
sns.violinplot(x = "good", y = "fixed acidity", hue = "good", data = df,\ palette="muted", split=True, inner = "quartile", bw=.2)
【问题讨论】:
标签: split violin-plot
我也在这个问题上苦苦挣扎,但只是想通了。 原因是您在“好”属性下有两个类别(0 和 1),这将导致 x 轴有两个 x-ticks(0 和 1)。
想象一个条形图,该图将有两个条形图,一个在 x-tick 0 处,另一个在 x-tick 1 处,两者永远不会相互接触。为了解决这个问题,我们只需要一个 x-tick。
您需要做的是创建一个具有单个值的虚拟列,然后将 x 轴设置为虚拟列,以便 x 轴有一个 x-tick。
df["dummy"] = "0" #have used 0 integer and the plot did not come out right
sns.violinplot(x = "dummy", y = "fixed acidity", hue = "good", data = df,\
palette="muted", split=True, inner = "quartile", bw=.2)
【讨论】: