Example #1
0
def set_line_styles(graphs):
    """
    Set different line styles, such that each line - color combination
    is present only once
    """
    n_colors = len(_defaultColors())
    line_styles = (1, 2, 8, 6)

    for i, g in enumerate(graphs):
        i_col = (i + 1) / n_colors
        g.SetLineStyle(line_styles[i_col])
        g.SetLineWidth(2)
Example #2
0
def set_marker_styles(graphs):
    """
    Set different marker styles, such that each marker - color
    combination is present only once
    """
    n_colors = len(_defaultColors())
    marker_styles = (20, 21, 22, 34, 47, 23, 33)

    for i, g in enumerate(graphs):
        i_col = (i + 1) / n_colors
        g.SetMarkerStyle(marker_styles[i_col])
        g.SetMarkerSize(1.5)
def make_fit_plot(ratioh, fit_res, fit_func, outbase):
    """Make a plot showing the ratio and the fit result"""
    from utils.TH_utils import calc_pulls
    from utils.plotHelpers import _defaultColors, mkplot, plotOnCanvas

    colors = _defaultColors()

    fit_func.SetParameters(*fit_res['params'])

    can = r.TCanvas('fit_plot_canvas', '', 800, 800)
    can.cd()
    hpad = r.TPad('hpad', 'hpad', 0, 0.25, 1, 1)
    r.SetOwnership(hpad, False)
    hpad.Draw()
    hpad.SetGrid()

    ratioh.GetYaxis().SetRangeUser(0, 1)
    ratioh.SetYTitle('N_{#chi_{c2}} / N_{#chi_{c1}}')
    plotOnCanvas(hpad, [ratioh, fit_func], drawOpt='E1')

    can.cd()
    ppad = r.TPad('ppad', 'ppad', 0, 0, 1, 0.25)
    r.SetOwnership(ppad, False)
    ppad.Draw()

    ppad.cd()
    ppad.SetGrid()
    plothist = ppad.DrawFrame(-1, -5, 1, 5)
    # plothist.SetXTitle('cos#theta')
    plothist.SetYTitle('(fit - data)/#sigma_{data}')
    plothist.GetYaxis().SetLabelSize(ratioh.GetYaxis().GetLabelSize() * 0.75 /
                                     0.25)
    plothist.GetYaxis().SetNdivisions(205)
    plothist.GetYaxis().SetTitleSize(ratioh.GetYaxis().GetTitleSize() * 0.75 /
                                     0.25)
    plothist.GetYaxis().SetTitleOffset(0.4)

    plothist.GetXaxis().SetLabelSize(ratioh.GetXaxis().GetLabelSize() * 0.75 /
                                     0.25)

    pulls = calc_pulls(ratioh, fit_func)
    pulls.SetMarkerStyle(2)
    pulls.SetMarkerSize(1)

    plotOnCanvas(ppad, [pulls], drawOpt='PE')

    can.Draw()
    plot_name = '_'.join([outbase, 'fit'])
    can.SaveAs(plot_name + '.pdf')