【发布时间】:2016-06-12 16:43:30
【问题描述】:
我第一次使用 seaborn,并尝试制作一个嵌套(分组)箱线图,其中数据点添加为点。这是我的代码:
import seaborn as sns
import pandas as pd
import matplotlib.pyplot as plt
tips = sns.load_dataset("tips")
sns.set(style="ticks")
## Draw a nested boxplot to show bills by day and sex
sns.boxplot(x="day", y="total_bill", hue="smoker",data=tips,width=0.5,palette="PRGn",linewidth=1)
## Draw a split strip plot
sns.stripplot(x="day", y="total_bill", hue="smoker",palette="PRGn",data=tips,size=4,edgecolor="gray",
split=True)
sns.despine(offset=10, trim=True)
plt.show()
由于箱线图中使用了 'width' 参数,您会看到点没有以框为中心。有什么办法可以将点与框对齐? boxplot 命令中的宽度参数是未对齐点的原因。
附言- 我已经添加了 tom 提到的 MCVE。
巴德
【问题讨论】:
标签: pandas matplotlib boxplot seaborn