コード例 #1
0
def dothatplot(whatphi):
    p = biggles.FramedArray(2, 1)
    x, y = makeplot(phi=whatphi, show="chi")
    x = list(x)
    y = list(y)
    x.append(0.)
    y.append(240.4)
    p[0, 0].add(biggles.Points(x, y, symboltype="filled circle"))
    p[0, 0].add(biggles.LineY(240.4))
    p[0, 0].add(biggles.LineY(240.4 + 1.))
    x, y = makeplot(phi=whatphi, show="area")
    x = list(x)
    y = list(y)
    x.append(0.)
    y.append(324.13)
    p[1, 0].add(biggles.Points(x, y, symboltype="filled circle"))
    #  p[1,0].add(biggles.LineY(324.13))
    #  p[1,0].add(biggles.LineY(324.13*0.99))
    p.xrange = 0., 3.
    p.ylabel = r"Area (MeV nb)               $\chi^2$"
    p.xlabel = r"$y_{ggg} / y_{qq} = sqrt(f B_{ggg} / B_{qq}$)"
    p[0, 0].yrange = 230., 330.
    p[1, 0].yrange = 310., 339.999
    p.title = r"Fit results with $\phi_g$ = " + str(whatphi) + r"$\degree$"
    p.write_eps("interference_nowwithphi_" + str(whatphi) + ".eps")
    p.show()
コード例 #2
0
def addtogroupsplot(p, csfunc, offset, color, kind):
    combinemap = {}
    combinemap[0] = []
    combinemap[1] = []
    combinemap[2] = []
    combinemap[3] = []
    combinemap[4] = []
    combinemap[5] = []
    combinemap[6] = []
    combinemap[7] = []
    combinemap[8] = []
    combinemap[9] = []
    for r in testsample:
        combinemap[0].append(csfunc(r))
        combinemap[groupify(r)].append(csfunc(r))
    groups = range(1, 10)
    hadgroup = [0] * 9
    hadgroup_err = [0] * 9
    for g in groups:
        hadgroup[g - 1], hadgroup_err[g - 1] = jt.wmean(combinemap[g])
    center_of_groups = jt.wmean(combinemap[0])[0]
    tmp = biggles.Points(Numeric.array(groups) + offset,
                         Numeric.array(hadgroup) / center_of_groups,
                         type=kind,
                         color=color)
    p.add(tmp)
    p.add(
        biggles.SymmetricErrorBarsY(Numeric.array(groups) + offset,
                                    Numeric.array(hadgroup) / center_of_groups,
                                    Numeric.array(hadgroup_err) /
                                    center_of_groups,
                                    color=color))
    p.add(biggles.LineY(1., type="longdashed"))
    return tmp
コード例 #3
0
ファイル: hexResults.py プロジェクト: tybiot/biskit
def plotInfo(info):
    """
    biggles FramedArray with only information labels
    """
    stat = biggles.FramedPlot()
    #stat.title = 'grouping info'

    ## turn off drawing of all axis related objects
    ## note: if all is turned off plotting doesnt work, so make one white
    stat.x.draw_ticks = 0
    stat.y.draw_ticks = 0
    stat.x.draw_ticklabels = 0
    stat.y.draw_ticklabels = 0
    stat.y.draw_spine = 0
    stat.x.spine_style['color'] = 'white'

    ## have to make it a plot - add a white line
    stat.add(biggles.LineY(0.01, type='dot', color='white'))

    ## add info lines one by one (from bottom and up!)
    info = string.split(info, '\n')
    for l in range(len(info)):
        yPos = 0.95 - 0.04 * l
        stat.add( biggles.PlotLabel( .05, yPos, info[l], halign='left', \
                                     size=1, face='courier' ) )
    return stat
コード例 #4
0
ファイル: hexResults.py プロジェクト: tybiot/biskit
def plotKey(data, name, key):
    ## plot the cluster rmsd dist.
    plot = biggles.FramedPlot()
    plot.add(biggles.PlotLabel(0.5, 0.90, name, size=4))

    ## customize plot appearence
    #plot.x1.label = 'cluster'
    plot.y2.label = 'size'
    plot.y1.label = key

    plot.x2.draw_ticks = 0
    plot.y2.draw_ticks = 0

    ## Plot
    plot.add(
        biggles.ErrorBarsY(clst_range, data[key][1], data[key][2], width=1))
    plot.add(biggles.Points(clst_range, data[key][0], type='cross', size=1))
    plot.add(biggles.LineY(0.25, type='dot'))

    ## add label with info about 'good' solutions
    good = []
    for clst in clst_range:
        if data[key][0][clst - 1] > 0.25:
            good += [clst]
    plot.add(biggles.PlotLabel(0.5, 0.80, str(good), size=1))

    return plot
コード例 #5
0
ファイル: a_multiDock.py プロジェクト: ostrokach/biskit
def plotLines(nr, style='dot', col='black', ref=None):
    """
    Greate a plot grid
    -> list of biggles objects
    """
    l = []

    for i in range(1, nr + 1):
        l += [biggles.LineY(i, type=style, color=col)]
        l += [biggles.LineX(i, type=style, color=col)]

    if ref:
        l += [biggles.LineY(ref[0], color='grey')]
        l += [biggles.LineX(ref[1], color='grey')]

    return l
コード例 #6
0
def add_curves(ax,
               x,
               y,
               lp,
               i,
               set_points=True,
               lock_levels=True,
               intervals=True,
               slopes=True,
               insets=True):
    if set_points and lp.haskey('lock_x'):
        ax.add(biggles.LineX(lp['lock_x'][i] * scale))
    if lock_levels and lp.haskey('lock_y'):
        ax.add(biggles.LineY(lp['lock_y'][i] * scale))
    if intervals and lp.haskey('left_x'):
        ax.add(biggles.LineX(lp['left_x'][i] * scale, type='dashed'))
    if intervals and lp.haskey('right_x'):
        ax.add(biggles.LineX(lp['right_x'][i] * scale, type='dashed'))
    if slopes:
        for d in ['up', 'dn']:
            if not lp.haskey('lock_%s_sl' % d): continue
            m, x0, y0 = [
                lp['lock_%s' % (e)][i]
                for e in ['%s_sl' % d, '%s_x' % d, 'y']
            ]
            ax.add(biggles.Slope(m, (x0 * scale, y0 * scale), type='dashed'))
コード例 #7
0
def plot_voltages(fs, vecs):
    import biggles

    all_values = np.concatenate( vecs )
    hi = all_values.max()
    lo = all_values.min()

    plot = biggles.Table(len(vecs), 1)
    plot.cellpadding = 0
    plot.cellspacing = 0
    for i,vec in enumerate(vecs):
        p = biggles.Plot()
        p.add( biggles.Curve(wv.t(fs, vec), vec) )
        p.yrange = (lo, hi)
        plot[i,0] = p


    p.add( biggles.LineX(0) )
    p.add( biggles.Label(0, (hi+lo)/2, "%.2f mV" % (hi-lo), halign='left') )

    p.add( biggles.LineY(lo) )
    p.add( biggles.Label((len(vec)/fs/2), lo, "%.1f ms" % (1000*len(vec)/fs), valign='bottom') )


    return plot
コード例 #8
0
def use_cross_section(csfunc, filename):
    hads = []
    hads_err = []
    for r in testsample:
        c, e = csfunc(r)
        hads.append(c)
        hads_err.append(e)
    hads_center = jt.wmean(zip(hads, hads_err))[0]

    p = biggles.FramedPlot()
    p.add(
        biggles.Points(range(len(testsample)),
                       Numeric.array(hads) / hads_center,
                       type="filled circle"))
    p.add(
        biggles.SymmetricErrorBarsY(range(len(testsample)),
                                    Numeric.array(hads) / hads_center,
                                    Numeric.array(hads_err) / hads_center))
    p.x1.draw_ticklabels = 0
    p.x1.label = "Runs by index"
    p.y1.label = "Normalized hadronic cross-section"
    p.add(biggles.LineY(1.))
    p.add(biggles.LineX(41.5, type="dashed"))
    l, r = 0.8, 1.2
    p.yrange = l, r + 0.001
    p.add(biggles.DataLabel(41.5 - 10, l + 0.15 * (r - l), "db16"))
    p.add(biggles.DataLabel(41.5 + 10, l + 0.15 * (r - l), "db17"))
    p.aspect_ratio = 8.5 / 11.
    p.show()
    p.write_eps(filename)
コード例 #9
0
ファイル: hex2complex.py プロジェクト: suliat16/biskit
def plot(complex_lst):
    ## plot the cluster rmsd dist.
    plot = biggles.FramedPlot()
    inset = biggles.FramedPlot()

    ## plot title
    plot.title = '/'.join(string.split(absfile(options['o']), '/')[-5:-1])

    ## customize plot appearence
    plot.x1.label = 'cluster'
    plot.y2.label = 'size'
    plot.y1.label = 'rmsd'

    plot.x2.draw_ticks = 0
    plot.y2.draw_ticks = 0

    inset.frame.draw_ticks = 0
    inset.x1.draw_ticklabels = 0
    inset.y1.draw_ticklabels = 0
    inset.y2.draw_ticklabels = 1
    inset.y2.draw_ticks = 1
    inset.y2.ticks_style['color'] = 'red'

    ## get cluter and rmsd lists
    clst_list = []
    rms_list = []
    for compl in complex_lst:
        clst_list += [compl.info['hex_clst']]
        rms_list += [compl.info['rms']]

    ## get average, max, min and size of cluster
    data = []
    clst_range = range(1, max(clst_list) + 1)
    for clst in clst_range:
        rms = compress(equal(clst_list, clst), rms_list)
        data += [[average(rms), max(rms), min(rms), len(rms)]]
    data = transpose(data)

    ## Inset
    inset.add(biggles.Curve(clst_range, data[3], color='red'))

    ## Plot
    plot.add(biggles.ErrorBarsY(clst_range, data[1], data[2]))
    plot.add(biggles.Points(clst_range, data[0], type='cross', size=1))
    plot.add(biggles.Inset((0.0, 0.0), (1.0, 1.0), inset))
    plot.add(biggles.LineY(10, type='dot'))

    ## add label with info about 'good' solutions (average rmsd < 10A)
    good = []
    for clst in clst_range:
        if data[0][clst - 1] < 10:
            good += [clst]
    plot.add(biggles.PlotLabel(0.5, 0.98, 'Solutions with rmsd < 10A', size=1))
    plot.add(biggles.PlotLabel(0.5, 0.95, str(good), size=1))

    ## plot and save
    plot.show()
    plot.write_eps(string.split(options['o'], '.')[0] + '.eps')
コード例 #10
0
def plotthree(h,
              title,
              filename=None,
              ghigh=0.966 * nbha["high"],
              ghoff=nbha["hoff"],
              glow=0.966 * nbha["low"],
              gloff=nbha["loff"]):
    #   hups = h["high"] - h["hoff"]*ptoc_high
    #   lups = h["low"] - h["loff"]*ptoc_low
    #   frac = hups/lups * 1.*ngam["low"]/ngam["high"]

    #   hups = h["high"]/float(ngam["high"]) - h["hoff"]/float(ngam["hoff"])
    #   lups = h["low"]/float(ngam["low"]) - h["loff"]/float(ngam["loff"])
    #   frac = hups/lups

    hups = h["high"] / float(ghigh) - h["hoff"] / float(ghoff)
    lups = h["low"] / float(glow) - h["loff"] / float(gloff)
    frac = hups / lups

    wm = jt.wmean(zip(frac.values, frac.errors))[0]

    sigmas = []
    for i in range(frac.bins):
        if frac.errors[i] > 0.:
            sigmas.append((frac.values[i] - wm) / frac.errors[i])
        else:
            sigmas.append(0.)

    p = biggles.FramedArray(3, 1)
    addtoplot(p[0, 0], hups)
    p[0, 0].yrange = 0., max(hups.values) * 1.1

    addtoplot(p[1, 0], frac)
    p[1, 0].add(biggles.LineY(wm))
    p[1, 0].yrange = 0.701, 1.299

    p[2, 0].add(biggles.Points(frac.bin_centers(), sigmas))
    p[2, 0].add(biggles.LineY(0.))
    p[2, 0].yrange = -4., 4.

    p.xlabel = title
    p.show()
    if filename != None: p.write_eps(filename)
コード例 #11
0
ファイル: test_examples.py プロジェクト: degerli/biggles
def test_example5():
    x = numpy.arange(0, 3 * numpy.pi, numpy.pi / 10)
    y = numpy.sin(x)

    a = biggles.FramedArray(2, 2, title='title')
    a.aspect_ratio = 0.75
    a.xlabel = "x label"
    a.ylabel = "y label"
    a.uniform_limits = 1
    a.cellspacing = 1.

    a += biggles.LineY(0, type='dot')
    a += [biggles.LineY(-1, type='dashed'), biggles.LineY(1, type='dashed')]

    a[0, 0].add(biggles.Curve(x, .25 * y))
    a[0, 1].add(biggles.Curve(x, .50 * y))
    a[1, 0].add(biggles.Curve(x, .75 * y))
    a[1, 1].add(biggles.Curve(x, y))

    _write_example(5, a)
コード例 #12
0
ファイル: test_examples.py プロジェクト: MrAureliusR/biggles
    def test_example11(self):
        p = biggles.FramedPlot()
        p.title = "title"
        p.xlabel = r"$x$"
        p.ylabel = r"$\Theta$"
        p.ylog = 1
        p.xlog = 1

        p.add(biggles.LineX(0.5))
        p.add(biggles.LineY(0.5))

        _write_example(11, p)
コード例 #13
0
def plotfrac(histhigh, histlow, histhoff, histloff, p):
    global numbha_high, numbha_low, numbha_hoff, numbha_loff
    histhigh.rootn()
    histlow.rootn()
    histhoff.rootn()
    histloff.rootn()

    upshigh = histhigh / float(numbha_high) - histhoff / float(numbha_hoff)
    upslow = histlow / float(numbha_low) - histloff / float(numbha_loff)
    frac = upshigh / upslow

    x, y, dy = frac.bin_centers(), frac.values, frac.errors
    ave = jt.wmean(zip(y, dy))[0]
    print ave
    p.add(biggles.Points(x, y, symboltype="filled circle", symbolsize=0.8))
    p.add(biggles.SymmetricErrorBarsY(x, y, dy))
    p.add(biggles.LineY(ave))
    return p
コード例 #14
0
def plotsig(histhigh, histlow, histhoff, histloff, p):
    global numbha_high, numbha_low, numbha_hoff, numbha_loff
    histhigh.rootn()
    histlow.rootn()
    histhoff.rootn()
    histloff.rootn()

    upshigh = histhigh / float(numbha_high) - histhoff / float(numbha_hoff)
    upslow = histlow / float(numbha_low) - histloff / float(numbha_loff)
    frac = upshigh / upslow

    x, y, dy = frac.bin_centers(), frac.values, frac.errors
    ave = jt.wmean(zip(y, dy))[0]
    sig = [-1000.] * len(y)
    for i in range(len(y)):
        try:
            sig[i] = (y[i] - ave) / dy[i]
        except ZeroDivisionError:
            sig[i] = -1000.
    p.add(biggles.Points(x, sig, symboltype="filled circle", symbolsize=0.8))
    p.add(biggles.LineY(0))
    p.yrange = -5, 5
    return p
コード例 #15
0
ファイル: example5.py プロジェクト: kirillsem/Biggles
#!/usr/bin/env python

import sys
sys.path.insert(1, '..')

import biggles
import math, numpy

x = numpy.arange(0, 3 * math.pi, math.pi / 10)
y = numpy.sin(x)

a = biggles.FramedArray(2, 2, title='title')
a.aspect_ratio = 0.75
a.xlabel = "x label"
a.ylabel = "y label"
a.uniform_limits = 1
a.cellspacing = 1.

a.add(biggles.LineY(0, type='dot'))

a[0, 0].add(biggles.Curve(x, .25 * y))
a[0, 1].add(biggles.Curve(x, .50 * y))
a[1, 0].add(biggles.Curve(x, .75 * y))
a[1, 1].add(biggles.Curve(x, y))

#a.write_img( 400, 400, "example5.png" )
#a.write_eps( "example5.eps" )
a.show()
コード例 #16
0
    yerr2 = []
    for i, n in enumerate(names):
        if n == "CLEO-III '05":
            x.append(i)
            y.append(gwhich[n][0])
            yerr1.append(gwhich[n][1])
            yerr2.append(sqrt(gwhich[n][1]**2 + gwhich[n][2]**2))
    return x, y, yerr1, yerr2


p = biggles.Table(1, 3)
p[0, 0] = biggles.FramedPlot()
p[0, 0].add(biggles.LineX(1.216, linetype="longdashed", linecolor="black"))
p[0, 0].add(biggles.LineX(1.216 + 0.027, linetype="dotted", linecolor="black"))
p[0, 0].add(biggles.LineX(1.216 - 0.027, linetype="dotted", linecolor="black"))
p[0, 0].add(biggles.LineY(0.5))
p[0, 0].add(
    biggles.PlotLabel(0.1,
                      0.95,
                      r"$\Upsilon(1S)$",
                      texthalign="left",
                      textvalign="top",
                      fontsize=5.))
x, y, yerr1, yerr2 = fillemup(g1)
p[0, 0].add(biggles.Points(y, x, symboltype="filled circle", symbolsize=1.5))
p[0, 0].add(biggles.SymmetricErrorBarsX(y, x, yerr1))
p[0, 0].add(biggles.SymmetricErrorBarsX(y, x, yerr2))
x, y, yerr1, yerr2 = fillemup_mine(g1)
p[0, 0].add(
    biggles.Points(y,
                   x,
コード例 #17
0
ファイル: example11.py プロジェクト: degerli/biggles
#!/usr/bin/env python
import biggles

p = biggles.FramedPlot()
p.title = "title"
p.xlabel = r"$x$"
p.ylabel = r"$\Theta$"
p.ylog = 1
p.xlog = 1

p.add(biggles.LineX(0.5))
p.add(biggles.LineY(0.5))

p.write("example11.png", dpi=55)
p.write("example11.eps")
p.write("example11.pdf")
p.show()
コード例 #18
0
def plot(
    x,
    y,
    y_rc,
    lock_points,
    plot_file,
    shape=(4, 2),
    img_size=None,
    scale=1. / 1000,
    title=None,
    xlabel=None,
    ylabel=None,
    titles=None,
    rows=None,
    cols=None,
    insets=None,
    lock_levels=True,
    set_points=False,
    intervals=False,
    slopes=False,
    scale_style='tight',
    label_style='row_col',
    format=None,
):

    nr, nc = y_rc
    cl, rl, rcl = False, False, False
    if label_style == 'col_only':
        cl = True
    elif label_style == 'row_col':
        rcl = True

    if slopes == True:

        def get(key, param):
            return lock_points.get('lock_%s%s' % (key, param), None)

        slopes = []
        for d in ['', 'up_', 'dn_']:
            m, x0, y0 = [get(d, p) for p in ['slope', 'x', 'y']]
            if m is not None:
                if y0 is None:
                    # Use default y-target if separate up/dn aren't there.
                    y0 = get('', 'y')
                slopes.append(zip(m, x0, y0))

    pl = util.plotGridder(y_rc,
                          plot_file,
                          title=title,
                          xlabel=xlabel,
                          ylabel=ylabel,
                          target_shape=shape,
                          img_size=img_size,
                          col_labels=cl,
                          rowcol_labels=rcl,
                          format=format)

    for r, c, ax in pl:
        if r >= nr or c >= nc: continue
        i = c + r * nc
        if set_points:
            ax.add(biggles.LineX(lock_points['lock_x'][i] * scale))
        if lock_levels:
            ax.add(biggles.LineY(lock_points['lock_y'][i] * scale))
        if intervals:
            ax.add(
                biggles.LineX(lock_points['left_x'][i] * scale, type='dashed'))
            ax.add(
                biggles.LineX(lock_points['right_x'][i] * scale,
                              type='dashed'))
        if slopes != False:
            for s in slopes:
                m, x0, y0 = s[i]
                ax.add(
                    biggles.Slope(m, (x0 * scale, y0 * scale), type='dashed'))
        if insets is not None:
            ax.add(
                biggles.PlotLabel(0.,
                                  0.,
                                  insets[i],
                                  halign='left',
                                  valign='bottom'))
        if x.shape == y.shape:
            ax.add(biggles.Curve(x[i] / 1000., y[i] / 1000.))
        else:
            ax.add(biggles.Curve(x / 1000., y[i] / 1000.))

        if scale_style == 'roll-off':
            # Prevent small signals from causing large tick labels
            hi, lo = amax(y[i]) / 1000, amin(y[i]) / 1000
            if hi - lo < 4:
                mid = (hi + lo) / 2
                ax.yrange = (mid - 2, mid + 2)
        elif scale_style == 'tight':
            hi, lo = amax(y[i]) / 1000., amin(y[i]) / 1000.
            dx = (hi - lo) * .1
            if dx <= 0:  # Never set a 0-size yrange.
                dx = 0.5
            ax.yrange = lo - dx, hi + dx
            if x.shape == y.shape:
                ax.xrange = x[i][0] / 1000., x[i][-1] / 1000.
            else:
                ax.xrange = x[0] / 1000., x[-1] / 1000.

    pl.cleanup()
    return {
        'plot_files': pl.plot_files,
    }
コード例 #19
0
ファイル: plotUtils.py プロジェクト: crawfordsm/HRSTool
def plot(yvecarr,
         xvecarr=None,
         color="black",
         title="",
         xsize=600,
         ysize=300,
         xrange=None,
         yrange=None,
         psfile=None):
    """
     Use biggles to plot the spectrum in the 'yvecarr' array. 'yvecarr' may be
     a 1-dimensional or a 2-dimensional array containing a single spectrum
     or a set of spectra, respectively
  """

    # Set the plotting screen to the demanded size
    biggles.configure('screen', 'width', xsize)
    biggles.configure('screen', 'height', ysize)

    # Prepare the frame object and give it a title
    frame = biggles.FramedPlot()
    frame.aspect_ratio = 0.5
    frame.title = title

    # Make sure yvecarr is defined and make sense of it
    if yvecarr is None:
        return
    else:
        try:
            nyvec, nypixels = numpy.shape(yvecarr)
        except ValueError:
            # Apparently, yvecarr is a one-dimensional array
            nyvec = 1
            nypixels = len(yvecarr)
            yvecarr = numpy.array([yvecarr])

    # If no xvecarr is defined, fill the x-axis array with increasing
    # integers
    if xvecarr is None:
        xvecarr = numpy.zeros((nyvec, nypixels), dtype=numpy.float64)
        nxpixels = nypixels
        for i in range(nyvec):
            xvecarr[i, :] = numpy.arange(nypixels)
    else:
        # If not, it is either a 1- or 2-dimensional array (similar to yvecarr)
        try:
            nxvec, nxpixels = numpy.shape(xvecarr)
        except ValueError:
            nxvec = 1
            nxpixels = len(xvecarr)
            xvecarr = numpy.array([xvecarr])

    # Make sure that x and y arrays have identical length.
    if (nxpixels != nypixels):
        print 'Unequal length of x- and y-data'
        return

    # Set the plotting x-range if this was specified
    if xrange:
        frame.xrange = xrange
    else:
        frame.xrange = (xvecarr.min(), xvecarr.max())

    # And similar for the y-range
    if yrange:
        frame.yrange = yrange
#  else :
#    frame.yrange = (yvecarr.min(), yvecarr.max())

# Now, start the loop over the spectra (or spectrum)
    for i in range(nyvec):

        # Select the x- and y-vectors

        try:
            xvec = xvecarr[i]
        except IndexError:
            xvec = range(0, len(yvec))

        yvec = yvecarr[i]

        # And plot these in the 'frame' object
        frame.add(biggles.Curve(xvec, yvec, color=color))

    # Also add a line indicating the zero-level
    frame.add(biggles.LineY(0, color='blue'))

    # And display this plot on screen
    frame.show()

    # Save to encapsulated postscript
    # CURRENTLY NOT IMPLEMENTED. FOR LARGE PLOTS THIS MAY RESULT IN HEAVY DISK I/O
    if psfile is not None:
        frame.write_img(xsize, ysize, psfile)

    # Return the object to the caller, in case it would like to do more with it...
    return frame
コード例 #20
0
ファイル: example5.py プロジェクト: degerli/biggles
#!/usr/bin/env python

import biggles
import math
import numpy

x = numpy.arange(0, 3 * math.pi, math.pi / 10)
y = numpy.sin(x)

a = biggles.FramedArray(2, 2, title='title')
a.aspect_ratio = 0.75
a.xlabel = "x label"
a.ylabel = "y label"
a.uniform_limits = 1
a.cellspacing = 1.

a += biggles.LineY(0, type='dot')
a += [biggles.LineY(-1, type='dashed'), biggles.LineY(1, type='dashed')]

a[0, 0].add(biggles.Curve(x, .25 * y))
a[0, 1].add(biggles.Curve(x, .50 * y))
a[1, 0].add(biggles.Curve(x, .75 * y))
a[1, 1].add(biggles.Curve(x, y))

a.write("example5.png", dpi=55)
a.write("example5.eps")
a.write("example5.pdf")
a.show()
コード例 #21
0
                  float(n4)))
    block5.append(float(b5) / float(n5))
    block5err.append(
        math.sqrt((float(b5) / float(n5)) * (1. - float(b5) / float(n5)) /
                  float(n5)))
    block6.append(float(b6) / float(n6))
    block6err.append(
        math.sqrt((float(b6) / float(n6)) * (1. - float(b6) / float(n6)) /
                  float(n6)))

p1 = biggles.FramedArray(2, 1)
p1[0,
   0].add(biggles.Points(rnum, eff, symboltype="filled circle",
                         symbolsize=0.2))
p1[0, 0].add(biggles.SymmetricErrorBarsY(rnum, eff, efferr))
p1[0, 0].add(biggles.LineY(1., linetype="dotted"))
p1[0, 0].yrange = (0.987, 1.005)
p1[0, 0].xrange = (min(rnum) - 100, max(rnum) + 100)
p1[1,
   0].add(biggles.Points(rnum, eff, symboltype="filled circle",
                         symbolsize=0.2))
p1[1, 0].add(biggles.SymmetricErrorBarsY(rnum, eff, efferr))
p1[1, 0].add(biggles.LineY(1., linetype="dotted"))
p1[1, 0].yrange = (0.8, 1.1)
p1[1, 0].xrange = (min(rnum) - 100, max(rnum) + 100)
p1.xlabel = "Run number"
p1.ylabel = "BarrelBhabha trigger efficiency"
p1[1, 0].add(biggles.PlotLabel(0.25, 0.25, "same outliers as last time"))
p1.show()
p1.write_eps("plottrig3_p1.eps")
print map(lambda (r, e): r, filter(lambda (r, e): e < 0.99, zip(rnum, eff)))
コード例 #22
0
def makep1(p1x, p1y, p1z, run):
    return sqrt(p1x**2 + p1y**2 + p1z**2) / runsummary[run].energy


print "zero", time.asctime(time.localtime(time.time()))
histhigh_p1peak.ntuple(high, makep1, hadron_peak_noconv)
print "one", time.asctime(time.localtime(time.time()))
histhoff_p1peak.ntuple(hoff, makep1, hadron_peak_noconv)
print "two", time.asctime(time.localtime(time.time()))

plotdiff(
    histhigh_p1peak, histlow_p1peak, histhoff_p1peak, histloff_p1peak,
    "Biggest track momentum (/ebeam) with charged energy > 0.98 ECOM and tracks > 4"
)
savefig("rootstab6_plotbb_p1peak_noconv.eps")

import biggles
h = (histhigh_p1peak / float(numbha_high) -
     histhoff_p1peak / float(numbha_hoff))
x, y, dy = h.bin_centers(), h.values, h.errors
p = biggles.FramedPlot()
p.add(biggles.Points(x, y, symboltype="filled circle", symbolsize=0.8))
p.add(biggles.SymmetricErrorBarsY(x, y, dy))
p.add(biggles.LineY(0))
p.add(biggles.LineX(0.8, linetype="dashed"))
p.x1.label = "p1 with charged energy > 0.98 ECOM and tracks > 4"
p.aspect_ratio = 1
p.y1.range = -3e-5, 7e-5
p.show()
p.write_eps("rootstab6_plotbb_p1peak_noconv.eps")
コード例 #23
0
       and not (75-2 < i < 82+2 and 58-2 < j < 62+2):
      num += allnumer[i,j]
      den += alldenom[i,j]
  thetanumer[i] += num
  thetadenom[i] += den
# thetanumer = Numeric.sum(Numeric.transpose(allnumer))
# thetadenom = Numeric.sum(Numeric.transpose(alldenom))
p = (hist.h1(100, 0., 1., vals=thetanumer)/hist.h1(100, 0., 1., vals=thetadenom)).plot(False, points=True, errorbars=True)
p.add(biggles.LineX(0.05, linetype="longdashed"))
p.add(biggles.LineX(0.19, linetype="longdashed"))
p.add(biggles.LineX(0.36, linetype="longdashed"))
p.add(biggles.LineX(0.52, linetype="longdashed"))
p.add(biggles.LineX(0.64, linetype="longdashed"))
p.add(biggles.LineX(0.75, linetype="longdashed"))
p.add(biggles.LineX(0.81, linetype="longdashed"))
p.add(biggles.LineY(1., linetype="solid"))
p.xrange = (0.0, 0.9)
p.yrange = (0.98, 1.002)
p.xlabel = r"|cos$\theta$| of tracks with tile divisions"
p.ylabel = r"$\epsilon$ with blocks A, B, C, removed"
p.show()
p.write_eps("plottrig2_4.eps")

# gamgams grow more slowly than bhabhas
# q = hist.h1(100, 0., 1., vals=thetadenom).plot()
# x = Numeric.arange(0., 0.99, 0.01)
# y = Numeric.arange(0., 0.99, 0.01)
# for i in range(len(y)):
#   y[i] = (1. + math.pow(x[i], 2)) / math.sqrt(1. - math.pow(x[i], 2)) * \
#          hist.h1(100, 0., 1., vals=thetadenom).int()
# q.add(biggles.Curve(x,y))
コード例 #24
0
                                  sigshist.underflow))) + r" runs total",
                      angle=90,
                      halign="left"))
sigsplot.show()
sigsplot.write_eps("plottrig_3.eps")

newplot = biggles.FramedArray(5, 1)
num = hist.h1(100, 0, 1)
den = hist.h1(100, 0, 1)
num.vals = 0. + Numeric.array(run[121928].numer)
den.vals = 0. + Numeric.array(run[121928].denom)
newplot[0, 0].add((num / den).points(True,
                                     symboltype="filled circle",
                                     symbolsize=1))
newplot[0, 0].add((num / den).errorbars(True))
newplot[0, 0].add(biggles.LineY(1, linetype="dotted"))
newplot[0, 0].add(biggles.LineX(0.45, linetype="longdashed"))
newplot[0, 0].add(biggles.LineX(0.70, linetype="longdashed"))
newplot[0, 0].add(biggles.PlotLabel(0.1, 0.85, "121928"))
newplot[0, 0].add(biggles.PlotLabel(0.675, 0.2, "accepted region"))
num = hist.h1(100, 0, 1)
den = hist.h1(100, 0, 1)
num.vals = 0. + Numeric.array(run[121929].numer)
den.vals = 0. + Numeric.array(run[121929].denom)
newplot[1, 0].add((num / den).points(True,
                                     symboltype="filled circle",
                                     symbolsize=1))
newplot[1, 0].add((num / den).errorbars(True))
newplot[1, 0].add(biggles.LineY(1, linetype="dotted"))
newplot[1, 0].add(biggles.LineX(0.45, linetype="longdashed"))
newplot[1, 0].add(biggles.LineX(0.70, linetype="longdashed"))
コード例 #25
0
    pull[0, 0], u1data["mar13"], mymar13,
    lambda w: u1func(myarea, myrfeb, myback, myfullgam, myyint, myphi,
                     mybtautau, mytauyint, mytauphi, mytwophofrac, w))
adddata_pull(
    pull[0, 0], u1data["apr08"], myapr08,
    lambda w: u1func(myarea, myrapr2, myback, myfullgam, myyint, myphi,
                     mybtautau, mytauyint, mytauphi, mytwophofrac, w))
adddata_pull(
    pull[0, 0], u1data["apr09"], myapr09,
    lambda w: u1func(myarea, myrapr2, myback, myfullgam, myyint, myphi,
                     mybtautau, mytauyint, mytauphi, mytwophofrac, w))
adddata_pull(
    pull[0, 0], u1data["apr10"], myapr10,
    lambda w: u1func(myarea, myrapr2, myback, myfullgam, myyint, myphi,
                     mybtautau, mytauyint, mytauphi, mytwophofrac, w))
pull[0, 0].add(biggles.LineY(0.))
pull[0, 0].x.range = 9.42, 9.51
pull[0, 0].x.ticks = [9.42, 9.45, 9.48, 9.51]
pull[0, 0].x.draw_ticklabels = 0
pull[0, 0].x.subticks = Numeric.arange(9.42, 9.51 + 0.01, 0.01)
pull[0, 0].y.range = -4., 4.
pull[0, 0].y.ticks = [-3., 0., 3.]
pull[0, 0].y.subticks = [-4., -3., -2., -1., 0., 1., 2., 3., 4.]
pull[0, 0].y2.draw_ticklabels = 0

myarea, myrmsbeam, myback, mymay29, myjun11, myjun12, myjul10, myjul24, myaug07, myfullgam, myyint, myphi, mybtautau, mytauyint, mytauphi, mytwophofrac, myu1area = fitrecord[
    2].values
thefunc = lambda w: u2func(myarea, myrmsbeam, myback, myfullgam, myyint, myphi,
                           mybtautau, mytauyint, mytauphi, mytwophofrac,
                           myu1area, w)
thefunc_bkgnd = lambda w: u2func_bkgndonly(
コード例 #26
0
p_reference = []
p_histogram = []
p_popLines = []

spectrum = colorSpectrum(len(e_key), 'FF0000', '00FF00')

for i in range(len(e_key)):
    ## plot data points
    p_energy += [ biggles.Points( l_fnc, e_val[i], color=spectrum[i],\
                                  size=1, type='filled circle') ]

    ## frame label
    p_label += [biggles.PlotLabel(.50, .90, e_key[i], size=6)]

    ## average energy line
    p_average += [biggles.LineY(average(e_val[i]), type='shortdashed')]

    ## reference complex energy line
    p_reference += [biggles.LineY(bind_ref[str(e_key[i])])]

    ## histogram inset
    inset = biggles.FramedPlot()
    inset.frame.draw_spine = 0
    inset.x2.draw_ticks = 0
    inset.x1.draw_ticks = 0
    inset.x1.draw_ticklabels = 0
    inset.y1.draw_ticklabels = 0
    inset.y1.draw_subticks = 0
    inset.y2.draw_ticks = 0
    dens = Biskit.hist.density(e_val[i], 25)
    inset.add(
コード例 #27
0
import biggles, Numeric

x = [9.460 - 0.020, 9.460, 10.023 - 0.020, 10.023, 10.355 - 0.020, 10.355]
y = [0.9990, 0.9921, 1.0002, 0.9969, 0.9983, 0.9928]
dy = [0.0025, 0.0020, 0.0017, 0.0037, 0.0029, 0.0023]

p = biggles.Table(2, 1)
p[0, 0] = biggles.FramedPlot()
p[0, 0].add(biggles.Points(x, y, symboltype="filled circle"))
p[0, 0].add(biggles.SymmetricErrorBarsY(x, y, dy))
p[0, 0].add(biggles.LineY(1.))
p[0, 0].x1.range = 9.3, 10.5
p[0, 0].y1.range = 0.985, 1.0035
p[0, 0].x1.label = "Center of mass energy (GeV)"
p[0, 0].y1.label = "BB lumi / GG lumi"

p[1, 0] = biggles.FramedPlot()
p[1,0].add(biggles.Curve([9.3, 9.4, 9.4, 9.5, 9.5, 10, 10, 10.1, 10.1, 10.3, 10.3, 10.4, 10.4, 10.5],\
                          Numeric.array([0, 0, 350.3*0.025/8.993, 350.3*0.025/8.993, 0, 0, 142.32*0.020/7.945, 142.32*0.020/7.945, 0, 0, 96.14*0.024/7.361, 96.14*0.024/7.361, 0, 0])*18/350.3))
p[1, 0].x1.range = 9.3, 10.5
p[1, 0].x1.label = "Center of mass energy (GeV)"
p[1, 0].y1.label = r"Size of $\Upsilon \to e^+e^-$ correction"
p[1, 0].y1.range = 0., 0.06

p.show()
p.write_eps("lumiratio.eps")
コード例 #28
0
]

y = y / sqrt(2.)
ye1 = ye1 / sqrt(2.)
ye2 = ye2 / sqrt(2.)
tell_me_about_it(9460.3)

y = y / (9460.3 / 2.) * 1.e6
ye1 = ye1 / (9460.3 / 2.) * 1.e6
ye2 = ye2 / (9460.3 / 2.) * 1.e6

p[0, 0] = biggles.FramedPlot()
p[0, 0].add(biggles.Points(x, y, symboltype="filled circle", symbolsize=1.5))
p[0, 0].add(biggles.ErrorBarsY(x, y - ye1, y + ye2))
p[0, 0].add(
    biggles.LineY(3.78739 / sqrt(2.) / (9460.3 / 2.) * 1.e6,
                  linetype="dashed"))
p[0, 0].x.ticks = x
p[0, 0].x.ticklabels = names
p[0, 0].x2.draw_ticklabels = 0
p[0, 0].x.draw_subticks = 0
p[0, 0].aspect_ratio = 0.3
p[0, 0].yrange = 400., 700.
p[0, 0].y1.label = r"$\Upsilon(1S)$ $\sigma_E/E$ $\times$ 10$^{6}$ in MeV"
p[0, 0].show()

x = range(6)
y = Numeric.array([
    4.28629322679, 4.01314654533, 4.25415201809, 3.91987316377, 3.7696777093,
    4.23821651803
])
ye1 = Numeric.array([
コード例 #29
0
ファイル: test_examples.py プロジェクト: MrAureliusR/biggles
    def test_labels(self):
        import numpy
        from numpy import linspace

        key = biggles.PlotKey(0.1, 0.9, halign='left')

        plt = biggles.FramedPlot(key=key, aspect_ratio=1)

        err = 0.1
        x = numpy.arange(10)
        y = numpy.arange(10)**2

        err = numpy.zeros(x.size) + 2
        ydata = y + numpy.random.normal(size=x.size) * err

        color = 'red'
        pts = biggles.Points(x,
                             ydata,
                             color=color,
                             type='filled diamond',
                             label='data')
        errpts = biggles.SymmetricErrorBarsY(x,
                                             ydata,
                                             err,
                                             color=color,
                                             label='data')

        model = biggles.Curve(x, y, label='model')

        plt += biggles.Polygon([0, 8, 4], [0, 0, 30],
                               color='grey20',
                               label='triangle')

        plt += [model, pts, errpts]

        plt += biggles.Point(4,
                             4,
                             type='filled circle',
                             color='cyan',
                             label='other')

        # Go from light blue to intense red.
        np = 30
        xp = linspace(0.5, 4, np)
        yp = 20 + 5 * xp.copy()
        minColor = [0.6, 0.9, 1.0]
        maxColor = [1.0, 0.2, 0.2]

        colors = numpy.zeros((np, 3))
        colors[:, 0] = numpy.interp(xp, xp,
                                    linspace(minColor[0], maxColor[0], np))
        colors[:, 1] = numpy.interp(xp, xp,
                                    linspace(minColor[1], maxColor[1], np))
        colors[:, 2] = numpy.interp(xp, xp,
                                    linspace(minColor[2], maxColor[2], np))

        plt += biggles.ColoredPoints(
            xp,
            yp,
            colors,
            type='cross',
            size=1,
            label='grad',
        )

        plt += biggles.LineX(5, color='green', label='lineY')
        plt += biggles.LineY(5, color='magenta', type='dashed', label='lineX')

        plt += biggles.Slope(-3, (0, 40), color='Hot Pink', label='slope')

        plt += biggles.DataBox([5.5, 70], [6.5, 80],
                               color='Dodger Blue',
                               label='box')

        # label doesn't work, nor does ellipses.  fundamental perhaps
        #plt += Circle(6.0, 75.0, 1,  color='yellow', label='circle')

        # not even sure how DataArc works
        #plt += DataArc(6.0, 75.0, 1,  color='yellow', label='circle')

        _write_example('labels', plt)
コード例 #30
0
ファイル: MatrixPlot.py プロジェクト: tybiot/biskit
    def __init__(self,
                 matrix,
                 mesh=0,
                 palette="plasma",
                 legend=0,
                 step=1,
                 vmin=None,
                 vmax=None):
        """
        @param matrix: the 2-D array to plot
        @type  matrix: array
        @param mesh: create a plot with a dotted mesh
        @type  mesh: 1|0
        @param palette: color palette name see L{Biskit.ColorSpectrum}
        @type  palette: str
        @param legend: create a legend (scale) showing the walues of the
                       different colors in the plot.  
        @type  legend: 1|0
        @param step: reduce matrix -- take only each step position in x and y
        @type  step: int

        @param vmin: override minimal value, all values below will revert
                     to default color

        @return: biggles plot object, view with biggles.FramedPlot.show() or
                 save with biggles.FramedPlot.write_eps(file_name).
        @rtype: biggles.FramedPlot
        """
        if not biggles:
            raise ImportError, 'biggles module could not be imported.'

        FramedPlot.__init__(self)

        if step != 1:
            matrix = self.__thinarray(matrix, step)

        if vmin is None:
            vmin = N0.amin(matrix)

        if vmax is None:
            vmax = N0.amax(matrix)
        self.palette = ColorSpectrum(palette, vmin=vmin, vmax=vmax)

        self.matrix = self.palette.color_array(matrix, resetLimits=0)
        s = N0.shape(self.matrix)

        for i in range(s[0]):
            for j in range(s[1]):

                col = self.matrix[i, j]

                x1 = (j, j + 1)
                y1 = (i, i)
                y2 = (i + 1, i + 1)

                cell = biggles.FillBetween(x1, y1, x1, y2, color=col)

                self.add(cell)

        if mesh:

            for i in range(s[0] + 1):
                self.add(biggles.LineY(i, linetype='dotted'))

            for i in range(s[1] + 1):
                self.add(biggles.LineX(i, linetype='dotted'))

        if legend:

            legend = self.__make_legend()

            self.add(legend)

            self.add(biggles.PlotBox((-0.17, -0.1), (1.25, 1.1)))

        self.aspect_ratio = 1.0