「rpyとgnuplot覚え書き」の編集履歴(バックアップ)一覧はこちら

rpyとgnuplot覚え書き - (2007/05/21 (月) 22:20:21) の最新版との変更点

追加された行は緑色になります。

削除された行は赤色になります。

http://www2.warwick.ac.uk/fac/sci/moac/currentstudents/peter_cock/python/lin_reg/ のplot部分をGnuplotで書いてみる。 from rpy import r import Gnuplot my_x = [5.05, 6.75, 3.21, 2.66] my_y = [1.65, 26.5, -5.93, 7.96] ls_fit = r.lsfit(my_x,my_y) gradient = ls_fit['coefficients']['X'] yintercept= ls_fit['coefficients']['Intercept'] #ここから g1 = Gnuplot.Gnuplot() g1.plot(zip(mx_x,my_y)) # sに直線の式のTemplateを作成 s = Template('$grad * x + ($itspt)') form1 = s.substitute(grad=gradiant,itspt=yintercept) '5.3935773612 * x + (-16.2811279931)' g1.plot(form1)
Rpyを使ってRに線形回帰(単なる直線回帰ですが)を させる方法を説明しているページ http://www2.warwick.ac.uk/fac/sci/moac/currentstudents/peter_cock/python/lin_reg/ のplot部分をGnuplot.pyを使ってGnuplotで書いてみる。 from rpy import r import Gnuplot my_x = [5.05, 6.75, 3.21, 2.66] my_y = [1.65, 26.5, -5.93, 7.96] ls_fit = r.lsfit(my_x,my_y) gradient = ls_fit['coefficients']['X'] yintercept= ls_fit['coefficients']['Intercept'] #ここから g1 = Gnuplot.Gnuplot() g1.plot(zip(mx_x,my_y)) # sに直線の式のTemplateを作成 s = Template('$grad * x + ($itspt)') form1 = s.substitute(grad=gradiant,itspt=yintercept) '5.3935773612 * x + (-16.2811279931)' g1.plot(form1)

表示オプション

横に並べて表示:
変化行の前後のみ表示: