Python Seaborn条纹图,点前有小提琴标绘条
我想画一个小提琴的情节后面的抖动条纹图。结果图在抖动点后面有一个平均值/标准条,这使得很难看到。我不知道有没有办法让酒吧在积分榜上名列前茅Python Seaborn条纹图,点前有小提琴标绘条,python,matplotlib,seaborn,Python,Matplotlib,Seaborn,我想画一个小提琴的情节后面的抖动条纹图。结果图在抖动点后面有一个平均值/标准条,这使得很难看到。我不知道有没有办法让酒吧在积分榜上名列前茅 import seaborn as sns import matplotlib.pyplot as plt tips = sns.load_dataset("tips") sns.violinplot(x="day", y="total_bill", data=tips, color="0.8") sns.stripplot(x="day", y="to
import seaborn as sns
import matplotlib.pyplot as plt
tips = sns.load_dataset("tips")
sns.violinplot(x="day", y="total_bill", data=tips, color="0.8")
sns.stripplot(x="day", y="total_bill", data=tips, jitter=True)
plt.show()
Seaborn不关心向用户公开它创建的对象。因此需要从轴上收集它们来操纵它们。您要在此处更改的属性是
zorder
。所以这个想法可以是
import seaborn as sns
import matplotlib.pyplot as plt
from matplotlib.collections import PathCollection
tips = sns.load_dataset("tips")
ax = sns.violinplot(x="day", y="total_bill", data=tips, color=".8")
for artist in ax.lines:
artist.set_zorder(10)
for artist in ax.findobj(PathCollection):
artist.set_zorder(11)
sns.stripplot(x="day", y="total_bill", data=tips, jitter=True, ax=ax)
plt.show()
我遇到了同样的问题,只需调整
sns.stripplot
中的zorder
参数即可解决:
import seaborn as sns
import matplotlib.pyplot as plt
tips = sns.load_dataset("tips")
sns.violinplot(x="day", y="total_bill", data=tips, color="0.8")
sns.stripplot(x="day", y="total_bill", data=tips, jitter=True, zorder=1)
plt.show()
结果与@ImportanceOfBeingErnest的答案相似:
Swarmlot怎么样?是的,可能有效,但我仍然希望能够在点上绘制平均值/性病标记。除非您向人们提供