0

R バージョンの ggplot を使用して、この質問に答えるために完全な Yhat doc を見つけることができませんでした。繰り返しソリューションに戻ろうとしました。

一般的に、Python ggplot プロットにテキストで注釈を付けるための正しい構文は何ですか?より具体的には Statsmodels の変数を使用します (以下のこのコード ブロックの最後の行を除いてすべてが機能します)?

from ggplot import *
    ggplot(aes(x='rundiff', y='winpct'), data=mlb_df) +\
    geom_point() + geom_text(aes(label='team'),hjust=0, vjust=0, size=10) +\
    stat_smooth(method='lm', color='blue') +\
    ggtitle('Contenders vs Pretenders') +\
    ggannotate('text', x = 4, y = 7, label = 'R^2')

ありがとう。

4

1 に答える 1

0

geom_text暫定的な解決策として使用できます

from ggplot import *
import pandas as pd
    dataText=pd.DataFrame.from_items([('x',[4]),('y',[7]),('text',['R^2'])])
    ggplot(aes(x='rundiff', y='winpct'), data=mlb_df) +\
    geom_point() + geom_text(aes(label='team'),hjust=0, vjust=0, size=10) +\
    stat_smooth(method='lm', color='blue') +\
    ggtitle('Contenders vs Pretenders') +\
    geom_text(aes(x='x', y='y', label='text'), data=dataText)
于 2015-03-04T23:52:47.400 に答える