0

无法找到完整的 Yhat 文档来回答这个问题,使用 ggplot 的 R 版本我试图迭代回到解决方案。

通常用文本注释 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 回答