我希望创建一个seaborn
pointplot
,在列中显示完整的数据分布,以及最低的25%的值和最高的25%的值的分布,并且并排(在x轴上)。
到目前为止,我的尝试为我提供了这些值,但它们只显示在x轴的同一部分上,而不是在图形上从左到右展开,并且没有明显的方法来标记x记号上的点(我更喜欢这样,而不是通过图例)。在
import seaborn as sns
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib notebook
df = sns.load_dataset('tips')
df1 = df[(df.total_bill < df.total_bill.quantile(.25))]
df2 = df[(df.total_bill > df.total_bill.quantile(.75))]
sns.pointplot(y=df['total_bill'], data=df, color='red')
sns.pointplot(y=df1['total_bill'], data=df1, color='green')
sns.pointplot(y=df2['total_bill'], data=df2, color='blue')
您可以使用宽格式
.join()
将新发行版df
然后.plot()
使用宽格式:获得:
如果要添加组,只需使用
^{pr2}$.unstack()
获得long
格式:获得:
我的思路是添加一个“组”,然后绘制成一个数据帧。在
相关问题 更多 >
编程相关推荐