Edgecolor of violinplot in Seaborn is not determined by the hue

天涯浪子 提交于 2019-12-12 02:23:00

问题


I have created a violinplot substantially similar to one in the Seaborn gallery:

import seaborn as sns
sns.set(style="whitegrid", palette="pastel", color_codes=True)

tips = sns.load_dataset("tips")

sns.violinplot(x="day", y="total_bill", hue="sex", data=tips, split=True,
           inner="quart", palette={"Male": "b", "Female": "y"})
sns.despine(left=True)

However, I have been unable to vary the edgecolor by hue ("Male" and "Female" in the example above). A previous answer on Stack Exchange solved this problem in the context of a Seaborn stripplot, but the geometry of the violinplot appears to require a different solution.


回答1:


I think this is just how seaborn's violinplot currently works. In the source code (site-packages/seaborn/distributions.py, in violinplot():

    for side in [-1, 1]:
        ax_plot((side * dens) + x, y, c=gray, lw=lw)

so:

When you find it on your system you can edit it.

The docstring is explicit that the color arguments are for the inside of the violins:

color : mpl color, sequence of colors, or seaborn palette name
        Inner violin colors


来源:https://stackoverflow.com/questions/31626433/edgecolor-of-violinplot-in-seaborn-is-not-determined-by-the-hue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!