Python,Seaborn – 如何在箱形图中添加有效条和星号

我正在寻找关于如何在盒子图上的方框之间添加显着性条的建议,并且还有代表重要性的星号.我正在使用seaborn创建情节,我找不到任何常用的方法来完成这个.在文档中没有任何事情发生在我身上,但我对matplotlib一般是新手和新手,所以如果我忽略某些事情,我不会感到惊讶.

I would like to be able to do something similar to this plot using R, but with python

最佳答案 @UlrichStern建议回答上一个完全符合我需要的问题.

How does one insert statistical annotations (stars or p-values) into matplotlib / seaborn plots?

在外行术语中,您绘制一条具有四个x值和四个y值的线.

plt.plot([x1,x1, x2, x2], [y1, y2, y2, y1], linewidth=1, color='k')

我的魔力在这里:

[x1, x1, x2, x2]
[y1, y2, y2, y1]

x1应该是您要指向的任何框的位置,x2应该是您想要指向的另一个框.

y2应该是您想要y轴上的线的位置,y1是您希望每端的垂直刻度延伸多远.

点赞