python boxplot significance_Python,Seaborn - 如何在箱形图中添加有效条和星号(Python, Seaborn - How to add significan...

Python,Seaborn - 如何在箱形图中添加有效条和星号(Python, Seaborn - How to add significance bars and asterisks to boxplots)

我正在寻找关于如何在箱形图上的方框之间添加显着性条的建议,并且还有代表重要性的星号。 我正在使用seaborn创建情节,我找不到任何常用的方法来完成这个。 文档中没有任何内容可以解决我的问题,但我一般都是matplotlib的新手和新手,所以如果我忽视某些事情,我不会感到惊讶。

I'm looking for suggestions on how to add significance bars between boxes on a box plot and also have asterisks representing significance. I am using seaborn to create plots and I couldn't find any common methods for accomplishing this. Nothing stuck out to me in the documentation but I am a novice and new to matplotlib in general so I wouldn't be surprised if I overlooked something.

原文:https://stackoverflow.com/questions/37707406

2019-12-07 21:34

满意答案

@UlrichStern建议回答上一个完全符合我需要的问题。

在外行术语中,您绘制一条具有四个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是你想要每端延伸的垂直刻度的距离。

@UlrichStern suggested an answer to a previous question that does exactly what I need.

In layman terms, you plot a line with four x values and four y values.

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

The magic for me was here:

[x1, x1, x2, x2]

[y1, y2, y2, y1]

x1 should be the location of whatever box you want to point to and x2 should be the other box you want to point to.

y2 should be where you want the line on the y-axis and y1 is how far down you want the vertical ticks on each end to extend.

2017-05-23

相关问答

我认为最简单的方法是使用sudo: sudo pip install seaborn

它需要sudo权限才能写入到usr/local/lib 。 注意:如果您使用的是anaconda,您将不需要通过pip安装sudo,只要您已经安装了conda,尽管seaborn也可以通过conda提供。 I think the easiest way is to use sudo: sudo pip install seaborn

It requires sudo permission to write t...

正如@ResMar在评论中指出的那样,在seaborn中似乎没有内置功能可以轻松设置单个错误栏。 如果您更关心结果而不是达到目标,那么以下(不那么优雅)的解决方案可能会有所帮助,它建立在matplotlib.pyplot.bar之上。 seaborn导入仅用于获得相同的风格。 import matplotlib.pyplot as plt

import seaborn as sns

import numpy as np

import pandas as pd

def grouped_barplo...

@UlrichStern建议回答上一个完全符合我需要的问题。 如何将统计注释(星号或p值)插入matplotlib / seaborn图? 在外行术语中,您绘制一条具有四个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应该是你想要...

您有两种不同的hue s,第一个绘制在位置的左侧,第二个绘制在位置的右侧。 这通常是需要的,例如参见文档中的这个图 import matplotlib.pyplot as plt

import seaborn as sns

tips = sns.load_dataset("tips")

ax = sns.boxplot(x="day", y="total_bill", hue="time",

data=tips, linewidth=2.5)

plt.sho...

capsize参数应该足够了,但出于某种原因,您必须指定cap.set_markeredgewidth以显示它们。基于: Matplotlib Errorbar Caps Missing 。 (_, caps, _) = plt.errorbar(

x_values, y_values, yerr=y_error, fmt='o', markersize=8, capsize=20)

for cap in caps:

cap.set_markeredgewidth(1)

收益:...

关于第一点,我们需要一个最小的,完整的,可验证的例子 。 为了在边条和轴之间放置空间,可以调整轴的边界。 ax.set_ylim(-1,N) ,其中N是条的数量。 可以使用plt.bar的width参数来设置条的width 。 plt.bar(..., width=1) ; 或者对于水平条,使用height参数。 海豹棒图不允许设置宽度或高度。 与2相同,只需使用ax.set_xlim(0,barmax*1.4) ,其中barmax是条的最大长度。 Concerning the first poi...

您想要的轴对象隐藏在ClusterGrid.ax_heatmap中。 这段代码找到了这个轴,并简单地使用ax.plot()来绘制这条线。 你也可以使用ax.axhline()。 import numpy as np

import seaborn as sns

import pandas as pd

import matplotlib.pyplot as plt

import random

data = np.random.random((50, 50))

df = pd.DataFrame(d...

如果您在链接的页面上进一步阅读(或ctrl-f代表“异常值”),您会看到: whis : float, optional

Proportion of the IQR past the low and high quartiles to extend the plot whiskers.

Points outside this range will be identified as outliers.

If you read further on the page you link...

我认为在这种情况下你不需要指定hue参数: In [136]: ax = sns.barplot(data=dfGroupedAgg, \

...: x='day_index', \

...: y='avg_duration', \

...: palette=sns.color_palette("Reds_d", n_colors=7, desat=1))

...

Seaborn基于matplotlib,并且Plotly转换它可以使用的matplotlib数字(其中mpl figure obejcts暴露了足够的信息来进行转换。以下是mpl转换文档: https : //plot.ly/matplotlib/ ) 在mpl 2.0发布之前,当mpl figure对象计划完全可序列化时,将无法完全覆盖。 Seaborn is based on matplotlib, and Plotly converts the matplotlib figures it c...

相关文章

在菜单中 增加了 click点击事件,事件代码如下: 'click' : function(n){

...

file(filename[,mode[,bufsize]]) 说明:file类型的构造函数

...

getattr(object,name[,defalut]) 说明:获取对象object名为

...

Python 编程语言具有很高的灵活性,它支持多种编程方法,包括过程化的、面向对象的和函数式的。但最重

...

callable(object) 说明:检查对象object是否可调用。如果返回True,ob

...

hasattr(object,name) 说明:判断对象object是否包含名为name的特

...

python2和python3的区别,1.性能 Py3.0运行 pystone benchmark的速

...

Python的文件类型 Python有三种文件类型,分别是源代码文件、字节码文件和优化代码文件

源代

...

python的官网:http://www.python.org/ 有两个版本,就像struts1和st

...

最新问答

如果启用了复制处理程序,请确保将其置于其中一个安全角色之后。 我见过人们做的另一件事是在不同的端口上运行admin。 最好在需要auth的页面上使用SSL,这样你就不会发送明确的密码,因此管理和复制将发生在8443上,而常规查询将在8080上发生。 如果您要签署自己的证书,请查看此有用的SO页面: 如何在特定连接上使用不同的证书? I didn't know that /admin was the context for SOLR admin because /admin does not re

第一:在您的样本中,您有: 但是你在询问 //td[@class=‘CarMiniProfile-TableHeader’] (注意TableHeader中的大写'T')。 xpath区分大小写。 第二:通过查询// td [@ class ='CarMiniProfile-TableHeader'] / td,你暗示你在外部td中有一个'td'元素,而它们是兄弟姐妹。 有很多方法可以在这里获得制作和模型

这是你的答案: http://jsfiddle.net/gPsdk/40/ .preloader-container { position: absolute; top: 0px; right: 0px; bottom: 0px; left: 0px; background: #FFFFFF; z-index: 5; opacity: 1; -webkit-transition: all 500ms ease-out;

问题是,在启用Outlook库引用的情况下, olMailItem是一个保留常量,我认为当您将Dim olMailItem as Outlook.MailItem ,这不是问题,但是尝试设置变量会导致问题。 以下是完整的解释: 您已将olMailItem声明为对象变量。 在赋值语句的右侧,在将其值设置为对象的实例之前,您将引用此Object 。 这基本上是一个递归错误,因为你有对象试图自己分配自己。 还有另一个潜在的错误,如果之前已经分配了olMailItem ,这个语句会引发另一个错误(可能是

我建议使用wireshark http://www.wireshark.org/通过记录(“捕获”)设备可以看到的网络流量副本来“监听”网络上发生的对话。 当您开始捕获时,数据量似乎过大,但如果您能够发现任何看起来像您的SOAP消息的片段(应该很容易发现),那么您可以通过右键单击并选择来快速过滤到该对话'关注TCP Stream'。 然后,您可以在弹出窗口中查看您编写的SOAP服务与Silverlight客户端之间的整个对话。 如果一切正常,请关闭弹出窗口。 作为一个额外的好处,wireshar

Android默认情况下不提供TextView的合理结果。 您可以使用以下库并实现适当的aligntment。 https://github.com/navabi/JustifiedTextView Android Does not provide Justified aligntment of TextView By default. You can use following library and achieve proper aligntment. https://github.com/

你的代码适合我: class apples { public static void main(String args[]) { System.out.println("Hello World!"); } } 我将它下载到c:\ temp \ apples.java。 以下是我编译和运行的方式: C:\temp>javac -cp . apples.java C:\temp>dir apples Volume in drive C is HP_PAV

12个十六进制数字(带前导0x)表示48位。 那是256 TB的虚拟地址空间。 在AMD64上阅读wiki(我假设你在上面,对吗?)架构http://en.wikipedia.org/wiki/X86-64 12 hex digits (with leading 0x) mean 48 bits. That is 256 TB of virtual address space. Read wiki on AMD64 (I assume that you are on it, right?) ar

这将取决于你想要的。 对象有两种属性:类属性和实例属性。 类属性 类属性对于类的每个实例都是相同的对象。 class MyClass: class_attribute = [] 这里已经为类定义了MyClass.class_attribute ,您可以使用它。 如果您创建MyClass实例,则每个实例都可以访问相同的class_attribute 。 实例属性 instance属性仅在创建实例时可用,并且对于类的每个实例都是唯一的。 您只能在实例上使用它们。 在方法__init__中定

你可能感兴趣的:(python,boxplot,significance)