예제 #1
0
파일: stats.py 프로젝트: ryneches/argweaver
def plotfuncFit(func, paramsInit, xdata, ydata, start, end, step, plot=None,
                **options):
    from rasmus import gnuplot

    if not plot:
        plot = gnuplot.Gnuplot()

    options.setdefault('style', 'boxes')

    params, resid = fitCurve(xdata, ydata, func, paramsInit)
    plot.plot(util.histbins(xdata), ydata, **options)
    plot.plotfunc(lambda x: func(x, params), start, end, step)

    return plot, params, resid
예제 #2
0
    if False:
        p = gnuplot.plotfunc(f, 0, 1, .1)
        p.plotfunc(g, 0, 1, .1)
        p.plotfunc(h, 0, 1, .1)

    if False:
        pts = [1, 2, 2, 3, 3, 1, -5, -4, -5, -3, -5, -2, -5, 0]
        p = gnuplot.plotfunc(interpolate(pts), 0, len(pts)-1, .1)

    def frange(n):
        return map(lambda x: x/float(n), range(n+1))

    pts = [0, 4, 0]
    pts2 = [0, 4, 6]

    p = gnuplot.Gnuplot()

    def make(n):
        times = frange(n)
        f = lambda p: lambda x: bspline(p, times, x)
        coords = map(f(pts), frange(10))
        coords2 = map(f(pts2), frange(10))

        p.plot(coords, coords2)

    times = frange(10)
    f = lambda p: lambda x: bspline2(p, times, x)
    coords = map(f(pts), frange(100))

    plots = util.unzip(coords)
    for plot in plots: