【发布时间】:2021-03-16 13:40:57
【问题描述】:
我试图在我的观点中同时使用style 和hue 来使用seaborn 可视化我的数据。请参见下面的示例。
import matplotlib.pyplot as plt
import seaborn as sns
df = sns.load_dataset('tips')
grid = sns.FacetGrid(data=df, row='smoker', col='day', hue='time', sharex=False, sharey=False)
grid.map_dataframe(sns.scatterplot, x='total_bill', y='tip', style='sex')
grid.add_legend()
输出如下。我也希望能够看到传说中的性别差异。我怎样才能做到这一点?例如,蓝色 x - 男性午餐,蓝色 * - 女性午餐,橙色 x - 男性晚餐,橙色 * - 女性晚餐。如果我什至可以使用sns.catplot 或任何其他方法也可以做到这一点。
【问题讨论】:
标签: python matplotlib seaborn