Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/sql-server-2008/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ipython PythonGGplot语法用Statsmodels变量注释图表?_Ipython_Statsmodels_Python Ggplot - Fatal编程技术网

Ipython PythonGGplot语法用Statsmodels变量注释图表?

Ipython PythonGGplot语法用Statsmodels变量注释图表?,ipython,statsmodels,python-ggplot,Ipython,Statsmodels,Python Ggplot,无法使用的R版本找到完整的Yhat文档来回答此问题 ggplot我尝试迭代返回到一个解决方案中 一般来说,用文本(更具体地说是使用Statsmodels中的变量)来注释Python ggplot的正确语法是什么?除了下面代码块的最后一行之外,所有的东西都可以工作 from ggplot import * ggplot(aes(x='rundiff', y='winpct'), data=mlb_df) +\ geom_point() + geom_text(aes(label='

无法使用的R版本找到完整的Yhat文档来回答此问题 ggplot我尝试迭代返回到一个解决方案中

一般来说,用文本(更具体地说是使用Statsmodels中的变量)来注释Python ggplot的正确语法是什么?除了下面代码块的最后一行之外,所有的东西都可以工作

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')
谢谢。

您可以使用geom_文本作为临时解决方案

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)

当前没有任何ggplot方法来注释绘图。您可以通过获取matplotlib图在matplotlib中执行此操作:g=ggplot…+。。。;图=g.draw。有关matplotlib中的注释,请参见@Janshulz的回复。典型的用例是支持将R平方、P值和模型方程添加到绘图中。仅供参考,Seaborn plot支持R2和P值注释,但不直接支持Statsmodels以及GGPlot。GGPlot可能不支持直接打印此类信息,如果有人添加注释(U Statsmodels)。。。但如果你想在seaborn拥有这样的东西,就去问问那里吧:-@Janshulz:几个月前,别人曾提出过关于ggplot的请求。从您对“某人”的回复来看,ggplot仅处于维护模式,没有进一步的积极开发?不,ggplot得到维护和处理,只是速度不如人们所希望的那样快:-据我所知,annotate_statsmodel不在ggplot的范围内,它试图尽可能接近ggplot2,AFAIK尚未对ggplot2进行注释。当然需要一个更通用的注释,但到目前为止,还没有人找到时间:-/