Python 如何手动输入seaborn jointplot stat_func的键值?
我想在seaborn jointplot上显示一些参数 让我们假设苹果=5就像皮尔逊=0.3 我对默认选项不感兴趣。因此,我用以下代码行生成了该图:Python 如何手动输入seaborn jointplot stat_func的键值?,python,seaborn,Python,Seaborn,我想在seaborn jointplot上显示一些参数 让我们假设苹果=5就像皮尔逊=0.3 我对默认选项不感兴趣。因此,我用以下代码行生成了该图: sns.jointplot(sp.time, mn, color="#4CB391", stat_func=None) 文件规定: stat_func : callable or None, optional Function used to calculate a statistic about the relationship and ann
sns.jointplot(sp.time, mn, color="#4CB391", stat_func=None)
文件规定:
stat_func : callable or None, optional
Function used to calculate a statistic about the relationship and annotate the plot.
Should map x and y either to a single value or to a (value, p) tuple.
Set to None if you don’t want to annotate the plot.
有没有人能帮我填写一下stat_func中正确显示我选择的键值对
多谢各位
绘图是您可以创建自己的函数,该函数接受两个输入参数(从调用
sns.jointplot()
得到x和y),并返回一个值或两个值的元组。如果您只想显示任意文本,最好使用@mwaskom对您的问题的评论中指出的ax.text()
。但是,如果你是从你自己的函数中计算一些东西,你可以这样做:
import seaborn as sns
tips = sns.load_dataset('tips')
def apples(x, y):
# Actual calculations go here
return 5
sns.jointplot('tip', 'total_bill', data=tips, stat_func=apples)
如果apples();p=0.3
只要返回格式是单个值或(value,p)
元组,就可以计算类似这样的任何统计数据。例如,如果您想使用scipy.stats.kendalltau
,您可以这样做
from scipy import stats
sns.jointplot('tip', 'total_bill', data=tips, stat_func=stats.kendalltau)
不要使用
stat\u func
如果您不是从数据中计算统计数据,只需在轴上添加文本即可。如果我要从scipy.stats计算统计数据,该怎么办。比如线性回归。