コード例 #1
0
ファイル: plotting.py プロジェクト: pbutti/optimization
def init_palette():
    from rootpy.plotting.style import set_style, get_style

    atlas = get_style("ATLAS")
    atlas.SetPalette(51)
    set_style(atlas)
    return True
コード例 #2
0
def main(parameters):
  style = get_style('CMSTDR')
  style.SetTitleSize(0.07, "XYZ")
  style.SetLegendBorderSize(0)
  style.SetLegendFillColor(0)
  style.SetLegendFont(43)
  style.SetTextSize(25)
  set_style(style)
  input_file = parameters.input_file
  plot_distributions(input_file, parameters.distribution_plots)
  plot_comparisons(input_file, parameters.comparison_plots)
コード例 #3
0
ファイル: utils.py プロジェクト: tcrapse/weaksupervision
def SetupATLAS():
    rootpy.log.basic_config_colorized()
    #use latex for text
    rc('text', usetex=True)
    # set the style
    style = get_style('ATLAS')
    style.SetEndErrorSize(3)
    set_style(style)
    set_style('ATLAS', mpl=True)
    rc('font', family='sans-serif', weight='medium', size=16)
    rc('legend', fontsize=16)
コード例 #4
0
ファイル: test.py プロジェクト: ekfriis/rootpy
def test_cmstdr():

    style = get_style('CMSTDR')
    with style:
        hpx = Hist(100, -4, 4, name="hpx", title="This is the px distribution")
        ROOT.gRandom.SetSeed()
        for i in xrange(1000):
            hpx.Fill(ROOT.gRandom.Gaus())
        hpx.GetXaxis().SetTitle("random variable [unit]")
        hpx.GetYaxis().SetTitle("#frac{dN}{dr} [unit^{-1}]")
        hpx.SetMaximum(100.)
        hpx.Draw()
コード例 #5
0
ファイル: test.py プロジェクト: schmitts/rootpy
def test_cmstdr():

    style = get_style('CMSTDR')
    with style:
        hpx = Hist(100, -4, 4, name="hpx", title="This is the px distribution")
        ROOT.gRandom.SetSeed()
        for i in xrange(1000):
            hpx.Fill(ROOT.gRandom.Gaus())
        hpx.GetXaxis().SetTitle("random variable [unit]")
        hpx.GetYaxis().SetTitle("#frac{dN}{dr} [unit^{-1}]")
        hpx.SetMaximum(100.)
        hpx.Draw()
        labels.CMS_label("Testing 2050", sqrts=100)
コード例 #6
0
def test_atlas():

    style = get_style('ATLAS')
    with style:
        hpx = Hist(100, -4, 4, name="hpx", title="This is the px distribution")
        ROOT.gRandom.SetSeed()
        for i in xrange(1000):
            hpx.Fill(ROOT.gRandom.Gaus())
        hpx.GetXaxis().SetTitle("random variable [unit]")
        hpx.GetYaxis().SetTitle("#frac{dN}{dr} [unit^{-1}]")
        hpx.SetMaximum(80.)
        hpx.Draw()
        ATLAS_label(.4, .8)
コード例 #7
0
ファイル: test.py プロジェクト: mhworth/rootpy
def test_lhcb():
    style = get_style('LHCb')

    with style:
        canvas = Canvas()
        hpx = Hist(100, -4, 4, name="hpx", title="This is the px distribution")
        ROOT.gRandom.SetSeed()
        for i in xrange(1000):
            hpx.Fill(ROOT.gRandom.Gaus())
        hpx.GetXaxis().SetTitle("random variable [unit]")
        hpx.GetYaxis().SetTitle("#frac{dN}{dr} [unit^{-1}]")
        hpx.SetMaximum(80.)
        hpx.Draw()
        LHCb_label("R", "preliminary")
        if INTERACTIVE:
            wait()
コード例 #8
0
ファイル: __init__.py プロジェクト: qbuat/htt
def set_hsg4_style(shape='square'):
    style = get_style('ATLAS', shape=shape)
    #style.SetFrameLineWidth(2)
    #style.SetLineWidth(2)
    #style.SetTitleYOffset(1.8)
    #style.SetTickLength(0.04, 'X')
    #style.SetTickLength(0.02, 'Y')

    # custom HSG4 modifications
    # style.SetPadTopMargin(0.06)
    style.SetPadLeftMargin(0.16)
    style.SetTitleYOffset(1.6)
    style.SetHistTopMargin(0.)
    style.SetHatchesLineWidth(1)
    style.SetHatchesSpacing(1)
    set_style(style)
コード例 #9
0
ファイル: test.py プロジェクト: akubera/rootpy
def test_cmstdr():

    style = get_style('CMSTDR')
    with style:
        canvas = Canvas()
        hpx = Hist(100, -4, 4, name="hpx", title="This is the px distribution")
        ROOT.gRandom.SetSeed()
        for i in xrange(1000):
            hpx.Fill(ROOT.gRandom.Gaus())
        hpx.GetXaxis().SetTitle("random variable [unit]")
        hpx.GetYaxis().SetTitle("#frac{dN}{dr} [unit^{-1}]")
        hpx.SetMaximum(100.)
        hpx.Draw()
        CMS_label("Testing 2050", sqrts=100)
        if INTERACTIVE:
            wait()
コード例 #10
0
ファイル: style.py プロジェクト: mayoub/hhana
def set_hsg4_style(shape='square'):
    style = get_style('ATLAS', shape=shape)
    #style.SetFrameLineWidth(2)
    #style.SetLineWidth(2)
    #style.SetTitleYOffset(1.8)
    #style.SetTickLength(0.04, 'X')
    #style.SetTickLength(0.02, 'Y')

    # custom HSG4 modifications
    # style.SetPadTopMargin(0.06)
    style.SetPadLeftMargin(0.16)
    style.SetTitleYOffset(1.6)
    style.SetHistTopMargin(0.)
    style.SetHatchesLineWidth(1)
    style.SetHatchesSpacing(1)
    ROOT.TGaxis.SetMaxDigits(4)
    set_style(style)
コード例 #11
0
ファイル: Utils.py プロジェクト: phylsix/FireROOT
def MyStyle():
    """customize ROOT style based on *CMSTDR* style"""

    style = get_style('CMSTDR')
    style.SetTitleSize(0.03, "XYZ")
    style.SetLabelSize(0.03, "XYZ")
    style.SetLegendBorderSize(0)
    style.SetLegendFillColor(0)
    font = 42  # Helvetica
    style.SetTextFont(font)
    style.SetLegendFont(43)
    style.SetPalette(ROOT.kBird)  # 55 ROOT.kCMYK # 112 ROOT.kViridis
    style.SetErrorX()
    style.SetPadTopMargin(0.05)
    style.SetPadBottomMargin(0.10)
    style.SetPadLeftMargin(0.12)
    style.SetPadRightMargin(0.04)
    return style
コード例 #12
0
ファイル: test_style.py プロジェクト: ndawe/rootpy
def test_get_style():

    mystyle = TStyle('mystyle', 'some style')
    assert(isinstance(get_style('mystyle'), Style))
コード例 #13
0
def test_get_style():

    mystyle = TStyle('mystyle', 'some style')
    assert (isinstance(get_style('mystyle'), Style))
コード例 #14
0
ファイル: plotting.py プロジェクト: kratsg/Optimization
def init_palette():
  from rootpy.plotting.style import set_style, get_style
  atlas = get_style('ATLAS')
  atlas.SetPalette(51)
  set_style(atlas)
  return True
コード例 #15
0
ファイル: fithist.py プロジェクト: AvivCukierman/resolution
def fithist(data,weightdata,central,eff=eff,plotDir=None):
  plotting = not (plotDir==None)
  if plotting and not os.path.exists(plotDir):
    print '== Making folder '+options.plotDir+' =='
    os.makedirs(options.plotDir)
  if plotting:
    try:
      from rootpy.plotting.style import set_style, get_style
      print '== Using ATLAS style =='
      atlas = get_style('ATLAS')
      atlas.SetPalette(51)
      set_style(atlas)
      set_style('ATLAS',mpl=True)
    except ImportError: print '== Not using ATLAS style (Can\'t import rootpy.) =='

  if plotting: n,bins,patches = plt.hist(data,normed=True,bins=100,weights=weightdata,facecolor='b',histtype='stepfilled')
  weightdata = weightdata/sum(weightdata)
  if central == 'absolute_median' or central == 'mode':
    if eff<0 or eff>1: raise RuntimeError('In order to use absolute IQR, you have to provide the reconstruction efficiency. Use --eff option.')
    (mu,mu_err,sigma,sigma_err,upper_quantile,lower_quantile,err) = distribution_values(data,weightdata,central,eff=eff)
    if plotting:
      plt.plot((mu,mu),(0,plt.ylim()[1]),'r--',linewidth=2)
      height = 0.607*max(n) #height at x=1*sigma in normal distribution
      if lower_quantile>float('-inf'):
        plt.plot((lower_quantile,upper_quantile),(height,height),'r--',linewidth=2)
        plt.plot((lower_quantile,lower_quantile),(height-0.02,height+0.02),'r-',linewidth=2)
      else:
        plt.plot((mu,upper_quantile),(height,height),'r--',linewidth=2)
      plt.plot((upper_quantile,upper_quantile),(height-0.02,height+0.02),'r-',linewidth=2)
  if central == 'median':
    (mu,mu_err,sigma,sigma_err,upper_quantile,lower_quantile) = distribution_values(data,weightdata,central)
    if plotting:
      plt.plot((mu,mu),(0,plt.ylim()[1]),'r--',linewidth=2)
      height = 0.607*max(n) #height at x=1*sigma in normal distribution
      plt.plot((lower_quantile,upper_quantile),(height,height),'r--',linewidth=2)
      plt.plot((lower_quantile,lower_quantile),(height-0.02,height+0.02),'r-',linewidth=2)
      plt.plot((upper_quantile,upper_quantile),(height-0.02,height+0.02),'r-',linewidth=2)
  if central == 'mean':
    (mu,mu_err,sigma,sigma_err) = distribution_values(data,weightdata,central)
    if plotting:
      gfunc = norm
      y = gfunc.pdf( bins, mu, sigma)
      plt.plot((mu,mu),(0,gfunc.pdf(mu,mu,sigma)),'r--',linewidth=2)
      l = plt.plot(bins, y, 'r--', linewidth=2)
  if central == 'trimmed':
    (mu,mu_err,sigma,sigma_err,lower,upper) = distribution_values(data,weightdata,central)
    if plotting:
      #print mu,sigma,ptbin
      gfunc = norm
      y = gfunc.pdf(bins, mu, sigma)
      plt.plot((mu,mu),(0,gfunc.pdf(mu,mu,sigma)),'r--',linewidth=2)
      newbins = bins[all([bins>lower,bins<upper],axis=0)]
      newy = y[all([bins>lower,bins<upper],axis=0)]
      l = plt.plot(newbins, newy, 'r--', linewidth=2)
  if plotting:
    plt.xlabel('$p_T^{reco}/p_T^{true}$')
    plt.ylabel('a.u.')
    plt.savefig(plotDir+'/'+'histfit_'+central+'.png')
    plt.close()
    #avgres.append(mu)
    #avgres_errs.append(mu_err)
    #sigmaRs.append(sigma)
    #sigmaR_errs.append(sigma_err)

  return mu,mu_err,sigma,sigma_err 
コード例 #16
0
ファイル: plot_style.py プロジェクト: suvayu/rootpy
import rootpy
rootpy.log.basic_config_colorized()
from rootpy.plotting import Canvas, Hist
from rootpy.plotting.style import get_style
from rootpy.interactive import wait

try:
    kwargs = {}
    for arg in extra:
        name, value = arg.lstrip('--').split('=')
        kwargs[name] = value
except ValueError:
    sys.exit("specify style parameters with --name=value")

try:
    style = get_style(args.style, **kwargs)
except ValueError:
    print('Invalid style: `{0}`. Using the `ATLAS` style.'.format(args.style))
    style = get_style('ATLAS')

# Use styles as context managers. The selected style will only apply
# within the following context:
with style:
    c = Canvas()
    hpx = Hist(100, -4, 4, name="hpx", title="This is the px distribution")
    # generate some random data
    ROOT.gRandom.SetSeed()
    for i in xrange(25000):
        hpx.Fill(ROOT.gRandom.Gaus())
    hpx.GetXaxis().SetTitle("random variable [unit]")
    hpx.GetYaxis().SetTitle("#frac{dN}{dr} [unit^{-1}]")
コード例 #17
0
ファイル: graph-cuts.py プロジェクト: pbutti/optimization
        help='Enable batch mode for ROOT.',
    )

    # parse the arguments, throw errors if missing any
    args = parser.parse_args()

    import ROOT

    ROOT.PyConfig.IgnoreCommandLineOptions = True
    ROOT.gROOT.SetBatch(args.batch_mode)

    import numpy as np

    from rootpy.plotting.style import set_style, get_style

    atlas = get_style('ATLAS')
    atlas.SetPalette(51)
    set_style(atlas)

    summary = json.load(file(args.summary))

    plot_array = {
        'sig': [r['significance'] for r in summary],
        'signal': [r['signal'] for r in summary],
        'bkgd': [r['bkgd'] for r in summary],
        'mgluino': [r['m_gluino'] for r in summary],
        'mlsp': [r['m_lsp'] for r in summary],
        'ratio': [r['ratio'] for r in summary],
    }

    # load in supercuts
コード例 #18
0
ファイル: plot_matplotlib_hist.py プロジェクト: jpata/rootpy
h1.linecolor = 'green'
h1.linewidth = 0

h2.fillstyle = 'solid'
h2.fillcolor = 'red'
h2.linecolor = 'red'
h2.linewidth = 0

stack = HistStack()
stack.Add(h1)
stack.Add(h2)
# hack to change y-axis range in ROOT
stack.SetMaximum(stack.GetMaximum() * 1.2)

# plot with ROOT
style = get_style('ATLAS')
style.SetEndErrorSize(3)
set_style(style)
canvas = Canvas(width=700, height=500)
stack.Draw('HIST E1 X0')
h3.Draw('SAME E1 X0')
stack.xaxis.SetTitle('Mass')
stack.yaxis.SetTitle('Events')
# set the number of expected legend entries
legend = Legend(3, leftmargin=0.45, margin=0.3)
legend.AddEntry(h1, style='F')
legend.AddEntry(h2, style='F')
legend.AddEntry(h3, style='LEP')
legend.Draw()
label = ROOT.TText(0.3, 0.8, 'ROOT')
label.SetTextFont(43)
コード例 #19
0
ファイル: plot_style.py プロジェクト: zhufengGNSS/rootpy
import ROOT
from rootpy.plotting import Canvas, Hist
from rootpy.plotting.style import get_style
from rootpy.interactive import wait
from rootpy.extern.six.moves import range

try:
    kwargs = {}
    for arg in extra:
        name, value = arg.lstrip('--').split('=')
        kwargs[name] = value
except ValueError:
    print("specify style parameters with --name=value")

try:
    style = get_style(args.style, **kwargs)
except ValueError:
    print('Invalid style: `{0}`. Using the `ATLAS` style.'.format(args.style))
    style = get_style('ATLAS')

# Use styles as context managers. The selected style will only apply
# within the following context:
with style:
    c = Canvas()
    hpx = Hist(100, -4, 4, name="hpx", title="This is the px distribution")
    # generate some random data
    ROOT.gRandom.SetSeed()
    for i in range(25000):
        hpx.Fill(ROOT.gRandom.Gaus())
    hpx.GetXaxis().SetTitle("random variable [unit]")
    hpx.GetYaxis().SetTitle("#frac{dN}{dr} [unit^{-1}]")
コード例 #20
0
 def __enter__(self):
     """Override the __enter__ method to remember the current gStyle.
     """
     self.old_gStyle = get_style(ROOT.gStyle.name)
     set_style(self)
     return self
コード例 #21
0
ファイル: plot_style.py プロジェクト: pombredanne/rootpy
Setting the plotting style
==========================

This example demonstrates how to set the plotting style.
"""
print __doc__
import ROOT
import rootpy

rootpy.log.basic_config_colorized()
from rootpy.plotting import Hist
from rootpy.plotting.style import get_style
from rootpy.interactive import wait


atlas_style = get_style("ATLAS")

# Use styles as context managers. The ATLAS style will only apply
# within the following context:
with atlas_style:
    hpx = Hist(100, -4, 4, name="hpx", title="This is the px distribution")
    # generate some random data
    ROOT.gRandom.SetSeed()
    for i in xrange(25000):
        hpx.Fill(ROOT.gRandom.Gaus())
    hpx.GetXaxis().SetTitle("random variable [unit]")
    hpx.GetYaxis().SetTitle("#frac{dN}{dr} [unit^{-1}]")
    hpx.SetMaximum(1000.0)
    hpx.Draw()
    wait()
コード例 #22
0
import rootpy

rootpy.log.basic_config_colorized()
from rootpy.plotting import Hist
from rootpy.plotting.style import get_style
from rootpy.interactive import wait

try:
    style_name = sys.argv[1]
except IndexError:
    print('Specify the style with the style name as an argument')
    print('Using the ATLAS style')
    style_name = 'ATLAS'

try:
    style = get_style(style_name)
except ValueError:
    print('Invalid style: `{}`. Using the `ATLAS` style.'.format(style_name))
    style = get_style('ATLAS')

# Use styles as context managers. The ATLAS style will only apply
# within the following context:
with style:
    hpx = Hist(100, -4, 4, name="hpx", title="This is the px distribution")
    # generate some random data
    ROOT.gRandom.SetSeed()
    for i in xrange(25000):
        hpx.Fill(ROOT.gRandom.Gaus())
    hpx.GetXaxis().SetTitle("random variable [unit]")
    hpx.GetYaxis().SetTitle("#frac{dN}{dr} [unit^{-1}]")
    hpx.SetMaximum(1000.)
コード例 #23
0
ファイル: __init__.py プロジェクト: sagittaeri/htt
    if not os.path.exists(dir):
        mkdir_p(dir)
    return dir

import numpy as np
# for reproducibilty
# especially for test/train set selection
np.random.seed(1987) # my birth year ;)

MMC_VERSION = 1
MMC_MASS = 'mmc%d_mass' % MMC_VERSION
MMC_PT = 'mmc%d_resonance_pt' % MMC_VERSION

from rootpy.plotting.style import get_style, set_style

style = get_style('ATLAS', shape='square')
#style.SetFrameLineWidth(2)
#style.SetLineWidth(2)
#style.SetTitleYOffset(1.8)
#style.SetTickLength(0.04, 'X')
#style.SetTickLength(0.02, 'Y')

# custom HSG4 modifications
style.SetPadLeftMargin(0.16)
style.SetTitleYOffset(1.6)

style.SetHistTopMargin(0.)
style.SetHatchesLineWidth(1)
style.SetHatchesSpacing(1)
set_style(style)
コード例 #24
0
ファイル: plot_style.py プロジェクト: apuignav/rootpy
import ROOT
import rootpy
rootpy.log.basic_config_colorized()
from rootpy.plotting import Hist
from rootpy.plotting.style import get_style
from rootpy.interactive import wait

try:
    style_name = sys.argv[1]
except IndexError:
    print('Specify the style with the style name as an argument')
    print('Using the ATLAS style')
    style_name = 'ATLAS'

try:
    style = get_style(style_name)
except ValueError:
    print('Invalid style: `{}`. Using the `ATLAS` style.'.format(style_name))
    style = get_style('ATLAS')

# Use styles as context managers. The ATLAS style will only apply
# within the following context:
with style:
    hpx = Hist(100, -4, 4, name="hpx", title="This is the px distribution")
    # generate some random data
    ROOT.gRandom.SetSeed()
    for i in xrange(25000):
        hpx.Fill(ROOT.gRandom.Gaus())
    hpx.GetXaxis().SetTitle("random variable [unit]")
    hpx.GetYaxis().SetTitle("#frac{dN}{dr} [unit^{-1}]")
    hpx.SetMaximum(1000.)
コード例 #25
0
ファイル: graph-grid.py プロジェクト: rsmith54/Optimization
#!/bin/env python2

import optparse,csv,sys
sys.argv.append("-b")
from ROOT import *
import rootpy as rpy
from rootpy.plotting.style import set_style, get_style
import os

atlas = get_style('ATLAS')
atlas.SetPalette(51)
set_style(atlas)
sys.argv = sys.argv[:-1]

topmass = 173.34

def parse_argv():

    parser = optparse.OptionParser()
    parser.add_option("--lumi", help="luminosity", default=5, type=int)
    #parser.add_option("--z-label", help="z axis title", default="significance in optimal cut")
    parser.add_option("--text-file", help="text csv file", default=None, type=str)
    parser.add_option("--outdir", help="outfile directory", default="plots")
    parser.add_option("--outfilebase", help="outfile base name", default="output")
    parser.add_option("--g-min", help="min gluino mass", default=800, type=float)
    parser.add_option("--g-max", help="max gluino mass", default=2000, type=float)
    parser.add_option("--l-min", help="min lsp mass", default=0, type=float)
    parser.add_option("--l-max", help="max lsp mass", default=1300, type=float)
    parser.add_option("--bin-width", help="bin width", default=100, type=float)
    parser.add_option("--x-dim", help="x dimension of figure", default=800, type=float)
    parser.add_option("--y-dim", help="y dimension of figure", default=600, type=float)
コード例 #26
0
ファイル: test_style.py プロジェクト: remenska/rootpy
def test_get_style():

    mystyle = TStyle("mystyle", "some style")
    assert isinstance(get_style("mystyle"), Style)
コード例 #27
0
import os.path, sys
from rootpy.plotting import F1, Hist, Hist2D, HistStack, Canvas, Legend, Pad
from rootpy.plotting.utils import draw
#from rootpy.interactive import wait
from rootpy.io import root_open
from rootpy.tree import Cut
from rootpy.plotting.style import get_style, set_style
from decimal import Decimal
import ROOT

ROOT.gROOT.SetBatch(True)
style = get_style('ATLAS')
style.SetEndErrorSize(3)
titlesize = 25
style.SetTitleSize(titlesize, "x")
style.SetTitleSize(titlesize, "y")
style.SetTitleYOffset(1)
#style.SetTitleXOffset(3)
#style.SetPadTopMargin(0.0)
#style.SetPadRightMargin(0.05)
#style.SetPadBottomMargin(0.2)
#style.SetPadLeftMargin(0.15)
#style.setPalette(51,0)
set_style(style)

labelmargin = 0.18  #Labeling

#==================== EDIT THESE ========================#
lumipb = 12300  #pb-1 (10 fb-1)
lumifb = lumipb / 1000.0
sqrts = 13
コード例 #28
0
ファイル: plot_style.py プロジェクト: ekfriis/rootpy
This example demonstrates how to set the plotting style.
"""
print __doc__
import sys
import ROOT
import rootpy
rootpy.log.basic_config_colorized()
from rootpy.plotting import Hist
from rootpy.plotting.style import get_style
from rootpy.interactive import wait

if len(sys.argv) == 1:
    print "you can also specify a style as argument"

style = get_style(sys.argv[1] if len(sys.argv) > 1 else 'ATLAS')

# Use styles as context managers. The ATLAS style will only apply
# within the following context:
with style:
    hpx = Hist(100, -4, 4, name="hpx", title="This is the px distribution")
    # generate some random data
    ROOT.gRandom.SetSeed()
    for i in xrange(25000):
        hpx.Fill(ROOT.gRandom.Gaus())
    hpx.GetXaxis().SetTitle("random variable [unit]")
    hpx.GetYaxis().SetTitle("#frac{dN}{dr} [unit^{-1}]")
    hpx.SetMaximum(1000.)
    hpx.Draw()
    wait()