python - 拆分 Seaborn 小提琴图表中的控制边
问题描述
有(如示例: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)
你得到:
是否可以控制两侧,即:指定“否”左和“是”右?
我遇到的问题是,在生成多个图时,我得到的图像在不同的侧面都有数据,例如:
我想在所有图像上都有“下降”,“上升”。
谢谢!
解决方案
是的,有可能,来自官方文档
order, hue_order : 字符串列表,可选
绘制分类级别的顺序,否则从数据对象中推断级别。
sns.violinplot(x="day", y="total_bill", hue="smoker",hue_order=['No','Yes'],
split=True, inner="quart",
palette={"Yes": "y", "No": "b"},
data=tips)
推荐阅读
- .net - 导入 .net 类型库时出现编译错误
- javascript - Javascript在逗号之间的括号内提取值(增加元素的变换函数参数)
- ios - 将自定义 UIView 笔尖的宽度设置为其父 CollectionViewCell
- java - spring boot中创建KafkaTemplate的正确方法
- angular - 如何在每个角度路线中发送请求
- node.js - 如何获取对象数组中的特定字段mongodb
- javascript - 尝试 console.log 来自 Prompt 的 2 个输入
- javascript - 将 stackblitz Angular 版本更新到最新版本
- sql - laravel 在搜索过滤器中仅显示相关数据
- c# - 线程中的代码导致标签不更新