【问题标题】:violin-plot: splitted parts aren't joinedSeaborn - 小提琴情节:分裂的部分没有加入
【发布时间】: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


    【解决方案1】:

    我也在这个问题上苦苦挣扎,但只是想通了。 原因是您在“好”属性下有两个类别(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)
    

    【讨论】:

      猜你喜欢
      • 2021-02-16
      • 2019-05-21
      • 2018-05-15
      • 1970-01-01
      • 2018-01-15
      • 2020-07-13
      • 2015-03-22
      • 2020-03-09
      • 2020-07-03
      相关资源
      最近更新 更多