有(如示例:https://seaborn.pydata.org/examples/grouped_violinplots.html)
sns.set(style="whitegrid", palette="pastel", color_codes=True)
# Load the example tips dataset
tips = sns.load_dataset("tips")
tips = tips[(tips['day'] == 'Sun')]
# Draw a nested violinplot and split the violins for easier comparison
sns.violinplot(x="day", y="total_bill", hue="smoker",
split=True, inner="quart",
palette={"Yes": "y", "No": "b"},
data=tips)
sns.despine(left=True)
你得到:
是否可以控制两侧,即:向左指定“否”,向右指定"is"?
我遇到的问题是,当生成多个图时,我得到的图像在不同侧面都有数据,例如:
我希望所有图像的左侧都有“向下”,右侧有“向上”。
谢谢!
最佳答案
是的,有可能,来自官方docs
order, hue_order : lists of strings, optional
Order to plot the categorical levels in, otherwise the levels are inferred from the data objects.
sns.violinplot(x="day", y="total_bill", hue="smoker",hue_order=['No','Yes'],
split=True, inner="quart",
palette={"Yes": "y", "No": "b"},
data=tips)
关于python - 分割 Seaborn fiddle 图表中的控制面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59460067/