2016-10-26 12 views
3

海底ジョイントプロットにいくつかのパラメータを表示したい。seaborn jointplot stat_funcに手動でキー値を入力するにはどうすればよいですか?

は、私はデフォルトのオプションに興味を持っていないですapples=5だけ

pearson=.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 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に埋めることができ、適切に私が選んだのキーと値のペアを表示しますか?

ありがとうございます。

プロットは、あなたはあなたに2つの入力パラメータ(呼び出しからsns.jointplot()にxとy)を取り、値または2つの値のタプルを返す独自の関数を作成することができますenter image description here

+0

をするだろうあなたがデータから統計を計算していない場合は 'stat_func'を使用しないでください、単に軸にテキストを追加します。 – mwaskom

+0

もし私がscipy.statsから統計量を計算するのであれば?線形回帰のようなものである。 –

答えて

0

です。任意のテキストを表示したいだけなら、@ 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) 

enter image description here

apples()はタプル(例えばreturn (5, 0.3))に2つの値を返された場合は、2番目の値はpとなるであろう結果のテキスト注釈はapples = 5; p = 0.3になります。

戻り値の形式が単一の値または(value, p)タプルである限り、このような統計はすべて計算できます。あなたはたとえばscipy.stats.kendalltauを使用する場合は、

from scipy import stats 
sns.jointplot('tip', 'total_bill', data=tips, stat_func=stats.kendalltau) 

enter image description here

関連する問題