def TopMassStyle(): """Set the style plot in order to create fancier plots!""" gStyle.SetPadTickX(1); gStyle.SetPadTickY(1); gStyle.SetHistLineWidth(3); gStyle.SetMarkerStyle(1); gStyle.SetTextSize(0.065); gStyle.SetOptFit(1111); gStyle.SetTitleSize(.05,"X");#.055 gStyle.SetTitleOffset(1.1,"X");#1.2,0.9 gStyle.SetLabelSize(.05,"X"); gStyle.SetTitleSize(.05,"Y");#.055 gStyle.SetTitleOffset(1.1,"Y"); gStyle.SetLabelSize(.05,"Y"); gStyle.SetPadLeftMargin(.16); gStyle.SetPadBottomMargin(.12); gStyle.SetTitleSize(.05,"Z"); gStyle.SetTitleOffset(1.8,"Z"); gStyle.SetLabelSize(0.06,"Z"); gStyle.SetLegendTextSize(0.04); gStyle.SetOptStat(112210); gStyle.SetPadLeftMargin(.12); gStyle.SetPadRightMargin(.02); gStyle.SetPadBottomMargin(.12); gStyle.SetPadTopMargin(.07); gStyle.SetPadGridX(1); gStyle.SetPadGridY(1);
def setPlotStyle(): gStyle.SetPadGridX(1) gStyle.SetPadGridY(1) gStyle.SetOptStat(1110) gStyle.SetLineWidth(2) gStyle.SetHistLineWidth(3) gStyle.SetPadTickX(1) gStyle.SetPadTickY(1) gStyle.SetTextFont(62) gStyle.SetLabelFont(62) gStyle.SetTitleFont(62) gStyle.SetLegendBorderSize(1) gStyle.SetLegendFont(62)
def set_root_style(stat=1110, grid=0, PadTopMargin=0.08, PadLeftMargin=0.10, TitleOffsetY=1.2): # must be used in the beginning from ROOT import gROOT, gStyle gROOT.SetBatch(1) gROOT.Reset() gStyle.SetOptTitle(1) gStyle.SetTitleFillColor(0) gStyle.SetTitleBorderSize(0) # gStyle.SetTitleFont(22) # gStyle.SetStatFont(22) # gStyle.SetStatColor(1) # gStyle.SetLabelFont(22,"X") # gStyle.SetLabelFont(22,"Y") gStyle.SetCanvasBorderMode(0) gStyle.SetCanvasColor(0) gStyle.SetCanvasDefX(0) gStyle.SetCanvasDefY(0) gStyle.SetFrameBorderMode(0) gStyle.SetFrameBorderSize(1) gStyle.SetFrameFillColor(0) gStyle.SetFrameFillStyle(0) gStyle.SetFrameLineColor(1) gStyle.SetFrameLineStyle(1) gStyle.SetFrameLineWidth(1) gStyle.SetPadTopMargin(PadTopMargin) gStyle.SetPadLeftMargin(PadLeftMargin) gStyle.SetPadRightMargin(0.05) gStyle.SetLabelSize(0.03, "XYZ") gStyle.SetTitleSize(0.04, "XYZ") gStyle.SetTitleOffset(TitleOffsetY, "Y") gStyle.SetPadBorderMode(0) gStyle.SetPadColor(0) gStyle.SetPadTickX(1) gStyle.SetPadTickY(1) gStyle.SetPadGridX(grid) gStyle.SetPadGridY(grid) gStyle.SetOptStat(stat) gStyle.SetStatColor(0) gStyle.SetStatBorderSize(1)
def __init__(self): # Setup argument parser self.parser = argparse.ArgumentParser() #self.parser.add_argument("--infile", default="histos.root", help="input file (default: %(default)s)") self.parser.add_argument( "--outdir", default="figures/", help="output directory (default: %(default)s)") self.parser.add_argument("-v", "--verbose", action="count", default=0, help="verbosity (default: %(default)s)") self.options = self.parser.parse_args() if not self.options.outdir.endswith("/"): self.options.outdir += "/" if not os.path.exists(self.options.outdir): os.makedirs(self.options.outdir) #if not os.path.isfile(self.options.infile): # raise Exception("File does not exist: %s" % self.options.infile) #self.options.tfile = TFile.Open(self.options.infile) self.options.palette = ("#333333", "#377eb8", "#e41a1c", "#984ea3", "#ff7f00", "#4daf4a") # Setup basic drawer gROOT.LoadMacro("tdrstyle.C") gROOT.ProcessLine("setTDRStyle();") #gROOT.ProcessLine("gErrorIgnoreLevel = kWarning;") gROOT.SetBatch(True) gStyle.SetNdivisions(510, "Y") gStyle.SetEndErrorSize(0) gStyle.SetPadGridX(True) gStyle.SetPadGridY(True) #gStyle.SetOptStat(111110) gStyle.SetPadRightMargin(0.05) gStyle.SetTitleOffset(1.1, "Y") gStyle.SetPalette(57) # kBird gStyle.SetNumberContours(50)
def setStyle(): gStyle.SetPadBorderMode(0) gStyle.SetFrameBorderMode(0) gStyle.SetPadBottomMargin(0.12) gStyle.SetPadLeftMargin(0.12) gStyle.SetCanvasColor(ROOT.kWhite) gStyle.SetCanvasDefH(600) #Height of canvas gStyle.SetCanvasDefW(600) #Width of canvas gStyle.SetCanvasDefX(0) #POsition on screen gStyle.SetCanvasDefY(0) gStyle.SetPadTopMargin(0.05) gStyle.SetPadBottomMargin(0.15) #0.13); gStyle.SetPadLeftMargin(0.11) #0.16); gStyle.SetPadRightMargin(0.05) #0.02); # For the Pad: gStyle.SetPadBorderMode(0) gStyle.SetPadColor(ROOT.kWhite) gStyle.SetPadGridX(ROOT.kFALSE) gStyle.SetPadGridY(ROOT.kFALSE) gStyle.SetGridColor(0) gStyle.SetGridStyle(3) gStyle.SetGridWidth(1) # For the frame: gStyle.SetFrameBorderMode(0) gStyle.SetFrameBorderSize(1) gStyle.SetFrameFillColor(0) gStyle.SetFrameFillStyle(0) gStyle.SetFrameLineColor(1) gStyle.SetFrameLineStyle(1) gStyle.SetFrameLineWidth(1) gStyle.SetAxisColor(1, "XYZ") gStyle.SetStripDecimals(ROOT.kTRUE) gStyle.SetTickLength(0.03, "XYZ") gStyle.SetNdivisions(505, "XYZ") gStyle.SetPadTickX(1) # To get tick marks on the opposite side of the frame gStyle.SetPadTickY(1) gStyle.SetGridColor(0) gStyle.SetGridStyle(3) gStyle.SetGridWidth(1) gStyle.SetTitleColor(1, "XYZ") gStyle.SetTitleFont(42, "XYZ") gStyle.SetTitleSize(0.05, "XYZ") gStyle.SetTitleXOffset(1.15) #0.9); gStyle.SetTitleYOffset(1.3) # => 1.15 if exponents gStyle.SetLabelColor(1, "XYZ") gStyle.SetLabelFont(42, "XYZ") gStyle.SetLabelOffset(0.007, "XYZ") gStyle.SetLabelSize(0.045, "XYZ") gStyle.SetPadBorderMode(0) gStyle.SetFrameBorderMode(0) gStyle.SetTitleTextColor(1) gStyle.SetTitleFillColor(10) gStyle.SetTitleFontSize(0.05) gStyle.SetOptStat(0) gStyle.SetOptTitle(0) gStyle.SetOptFit(1) NRGBs = 5 NCont = 255 stops = [0.00, 0.34, 0.61, 0.84, 1.00] red = [0.00, 0.00, 0.87, 1.00, 0.51] green = [0.00, 0.81, 1.00, 0.20, 0.00] blue = [0.51, 1.00, 0.12, 0.00, 0.00] stopsArray = array('d', stops) redArray = array('d', red) greenArray = array('d', green) blueArray = array('d', blue) TColor.CreateGradientColorTable(NRGBs, stopsArray, redArray, greenArray, blueArray, NCont) gStyle.SetNumberContours(NCont)
def set_root_env(): #//TStyle* genieStyle = new TStyle("genieStyle", "GENIE Style") #//set the background color to white gStyle.SetFillColor(10) gStyle.SetFrameFillColor(10) gStyle.SetCanvasColor(10) gStyle.SetPadColor(10) gStyle.SetTitleFillColor(0) gStyle.SetStatColor(10) #dont put a colored frame around the plots gStyle.SetFrameBorderMode(0) gStyle.SetCanvasBorderMode(0) gStyle.SetPadBorderMode(0) gStyle.SetLegendBorderSize(3) #use the primary color palette #gStyle.SetPalette(1,0) #set the default line color for a histogram to be black gStyle.SetHistLineColor(ROOT.kBlack) #set the default line color for a fit function to be red gStyle.SetFuncColor(ROOT.kRed) #make the axis labels black gStyle.SetLabelColor(ROOT.kBlack, "xyz") #set the default title color to be black gStyle.SetTitleColor(ROOT.kBlack) #set the margins gStyle.SetPadBottomMargin(0.18) gStyle.SetPadTopMargin(0.08) gStyle.SetPadRightMargin(0.08) gStyle.SetPadLeftMargin(0.17) #set axis label and title text sizes gStyle.SetLabelFont(42, "xyz") gStyle.SetLabelSize(0.04, "xyz") gStyle.SetLabelOffset(0.015, "xyz") gStyle.SetTitleFont(42, "xyz") gStyle.SetTitleSize(0.04, "xyz") gStyle.SetTitleOffset(1.4, "y") gStyle.SetTitleOffset(1.3, "x") gStyle.SetStatFont(42) gStyle.SetStatFontSize(0.07) gStyle.SetTitleBorderSize(1) gStyle.SetStatBorderSize(0) gStyle.SetTextFont(42) gStyle.SetTitleW(0.5) gStyle.SetTitleH(0.1) #set line widths gStyle.SetFrameLineWidth(2) gStyle.SetFuncWidth(2) gStyle.SetHistLineWidth(2) #set the number of divisions to show gStyle.SetNdivisions(506, "xy") #gStyle.SetPadTickX(-50202) #turn off xy grids gStyle.SetPadGridX(0) gStyle.SetPadGridY(0) #set the tick mark style gStyle.SetPadTickX(1) gStyle.SetPadTickY(1) #turn off stats gStyle.SetOptStat(0) gStyle.SetOptFit(0) #marker/line settings #gStyle.SetMarkerStyle(20) gStyle.SetMarkerSize(.95) #0.7 gStyle.SetLineWidth(2) gStyle.SetErrorX(0) gStyle.SetHistLineStyle(0) #It was 3 for a dotted line #done gStyle.cd() gROOT.ForceStyle()
def setgstyle(): # Zero horizontal error bars gStyle.SetErrorX(0) # For the canvas gStyle.SetCanvasBorderMode(0) gStyle.SetCanvasColor(0) gStyle.SetCanvasDefH(800) # Height of canvas gStyle.SetCanvasDefW(800) # Width of canvas gStyle.SetCanvasDefX(0) # Position on screen gStyle.SetCanvasDefY(0) # For the frame gStyle.SetFrameBorderMode(0) gStyle.SetFrameBorderSize(1) gStyle.SetFrameFillColor(1) gStyle.SetFrameFillStyle(0) gStyle.SetFrameLineColor(1) gStyle.SetFrameLineStyle(0) gStyle.SetFrameLineWidth(1) # For the Pad gStyle.SetPadBorderMode(0) gStyle.SetPadColor(0) gStyle.SetPadGridX(False) gStyle.SetPadGridY(False) gStyle.SetGridColor(0) gStyle.SetGridStyle(3) gStyle.SetGridWidth(1) # Margins gStyle.SetPadTopMargin(0.08) gStyle.SetPadBottomMargin(0.19) gStyle.SetPadLeftMargin(0.17) #gStyle.SetPadRightMargin(0.07) # For the histo: gStyle.SetHistLineColor(1) gStyle.SetHistLineStyle(0) gStyle.SetHistLineWidth(2) gStyle.SetMarkerSize(1.4) gStyle.SetEndErrorSize(4) # For the statistics box: gStyle.SetOptStat(0) # For the axis gStyle.SetAxisColor(1, "XYZ") gStyle.SetTickLength(0.03, "XYZ") gStyle.SetNdivisions(510, "XYZ") gStyle.SetPadTickX(1) gStyle.SetPadTickY(1) gStyle.SetStripDecimals(False) # For the axis labels and titles gStyle.SetTitleColor(1, "XYZ") gStyle.SetLabelColor(1, "XYZ") gStyle.SetLabelFont(42, "XYZ") gStyle.SetLabelOffset(0.007, "XYZ") gStyle.SetLabelSize(0.045, "XYZ") gStyle.SetTitleFont(42, "XYZ") gStyle.SetTitleSize(0.06, "XYZ") # For the legend gStyle.SetLegendBorderSize(0)
def tdrGrid(gridOn=True): gStyle.SetPadGridX(gridOn) gStyle.SetPadGridY(gridOn) gStyle.SetGridColor(TStyle.kGray)
def setStyle(): gStyle.SetCanvasColor(0) gStyle.SetCanvasBorderSize(10) gStyle.SetCanvasBorderMode(0) gStyle.SetCanvasDefH(700) gStyle.SetCanvasDefW(700) gStyle.SetPadColor(0) gStyle.SetPadBorderSize(10) gStyle.SetPadBorderMode(0) gStyle.SetPadBottomMargin(0.13) gStyle.SetPadTopMargin(0.08) gStyle.SetPadLeftMargin(0.15) gStyle.SetPadRightMargin(0.05) gStyle.SetPadGridX(0) gStyle.SetPadGridY(0) gStyle.SetPadTickX(1) gStyle.SetPadTickY(1) gStyle.SetFrameFillStyle(0) gStyle.SetFrameFillColor(0) gStyle.SetFrameLineColor(1) gStyle.SetFrameLineStyle(0) gStyle.SetFrameLineWidth(1) gStyle.SetFrameBorderSize(10) gStyle.SetFrameBorderMode(0) gStyle.SetNdivisions(505) gStyle.SetLineWidth(2) gStyle.SetHistLineWidth(2) gStyle.SetFrameLineWidth(2) gStyle.SetLegendFillColor(root.kWhite) gStyle.SetLegendFont(42) gStyle.SetMarkerSize(1.2) gStyle.SetMarkerStyle(20) gStyle.SetLabelSize(0.040, "X") gStyle.SetLabelSize(0.040, "Y") gStyle.SetLabelOffset(0.010, "X") gStyle.SetLabelOffset(0.010, "Y") gStyle.SetLabelFont(42, "X") gStyle.SetLabelFont(42, "Y") gStyle.SetTitleBorderSize(0) gStyle.SetTitleFont(42) gStyle.SetTitleFont(42, "X") gStyle.SetTitleFont(42, "Y") gStyle.SetTitleSize(0.045, "X") gStyle.SetTitleSize(0.045, "Y") gStyle.SetTitleOffset(1.4, "X") gStyle.SetTitleOffset(1.4, "Y") gStyle.SetTextSize(0.055) gStyle.SetTextFont(42) gStyle.SetOptStat(0)
def initStyle(): gROOT.SetStyle("Plain") # For the canvas: gStyle.SetCanvasBorderMode(0) gStyle.SetCanvasColor(kWhite) gStyle.SetCanvasDefH(700) #Height of canvas gStyle.SetCanvasDefW(700) #Width of canvas gStyle.SetCanvasDefX(0) #Position on screen gStyle.SetCanvasDefY(0) # For the line: gStyle.SetLineWidth(2) # For the Pad: gStyle.SetPadBorderMode(0) # gStyle.SetPadBorderSize(Width_t size = 1) gStyle.SetPadColor(kWhite) gStyle.SetPadGridX(True) gStyle.SetPadGridY(True) gStyle.SetGridColor(0) gStyle.SetGridStyle(3) gStyle.SetGridWidth(1) # For the frame: gStyle.SetFrameBorderMode(0) gStyle.SetFrameBorderSize(1) gStyle.SetFrameFillColor(0) gStyle.SetFrameFillStyle(0) gStyle.SetFrameLineColor(1) gStyle.SetFrameLineStyle(1) gStyle.SetFrameLineWidth(1) # For the histo: # gStyle.SetHistFillColor(1) # gStyle.SetHistFillStyle(0) gStyle.SetHistLineColor(1) gStyle.SetHistLineStyle(0) gStyle.SetHistLineWidth(2) # gStyle.SetLegoInnerR(Float_t rad = 0.5) # gStyle.SetNumberContours(Int_t number = 20) gStyle.SetEndErrorSize(2) #gStyle.SetErrorMarker(20) gStyle.SetErrorX(0.) gStyle.SetMarkerStyle(8) gStyle.SetMarkerSize(1) #For the fit/function: gStyle.SetOptFit(0) gStyle.SetFitFormat("5.4g") gStyle.SetFuncColor(2) gStyle.SetFuncStyle(1) gStyle.SetFuncWidth(1) #For the date: gStyle.SetOptDate(0) # gStyle.SetDateX(Float_t x = 0.01) # gStyle.SetDateY(Float_t y = 0.01) # For the statistics box: gStyle.SetOptFile(0) gStyle.SetOptStat(0) # To display the mean and RMS: SetOptStat("mr") gStyle.SetStatColor(kWhite) gStyle.SetStatFont(42) gStyle.SetStatFontSize(0.025) gStyle.SetStatTextColor(1) gStyle.SetStatFormat("6.4g") gStyle.SetStatBorderSize(1) gStyle.SetStatH(0.1) gStyle.SetStatW(0.15) # gStyle.SetStatStyle(Style_t style = 1001) # gStyle.SetStatX(Float_t x = 0) # gStyle.SetStatY(Float_t y = 0) # Margins: gStyle.SetPadTopMargin(0.11) gStyle.SetPadBottomMargin(0.13) gStyle.SetPadLeftMargin(0.17) gStyle.SetPadRightMargin(0.07) # For the Global title: gStyle.SetOptTitle(0) gStyle.SetTitleFont(42) gStyle.SetTitleColor(1) gStyle.SetTitleTextColor(1) gStyle.SetTitleFillColor(10) gStyle.SetTitleFontSize(0.04) # gStyle.SetTitleH(0) # Set the height of the title box # gStyle.SetTitleW(0) # Set the width of the title box #gStyle.SetTitleX(0.35) # Set the position of the title box #gStyle.SetTitleY(0.986) # Set the position of the title box # gStyle.SetTitleStyle(Style_t style = 1001) #gStyle.SetTitleBorderSize(0) # For the axis titles: gStyle.SetTitleColor(1, "XYZ") gStyle.SetTitleFont(42, "XYZ") gStyle.SetTitleSize(0.05, "XYZ") # gStyle.SetTitleXSize(Float_t size = 0.02) # Another way to set the size? # gStyle.SetTitleYSize(Float_t size = 0.02) gStyle.SetTitleXOffset(1.) gStyle.SetTitleYOffset(1.3) #gStyle.SetTitleOffset(1.1, "Y") # Another way to set the Offset # For the axis labels: gStyle.SetLabelColor(1, "XYZ") gStyle.SetLabelFont(42, "XYZ") gStyle.SetLabelOffset(0.007, "XYZ") gStyle.SetLabelSize(0.035, "XYZ") # For the axis: gStyle.SetAxisColor(1, "XYZ") gStyle.SetStripDecimals(True) gStyle.SetTickLength(0.03, "XYZ") gStyle.SetNdivisions(510, "XYZ") gStyle.SetPadTickX( 1) # To get tick marks on the opposite side of the frame gStyle.SetPadTickY(1) # Change for log plots: gStyle.SetOptLogx(0) gStyle.SetOptLogy(0) gStyle.SetOptLogz(0) gStyle.SetPalette(1) #(1,0) # another top group addition gStyle.SetHatchesSpacing(1.0) # Postscript options: gStyle.SetPaperSize(20., 20.) #gStyle.SetPaperSize(TStyle.kA4) #gStyle.SetPaperSize(27., 29.7) #TGaxis.SetMaxDigits(3) # gStyle.SetLineScalePS(Float_t scale = 3) # gStyle.SetLineStyleString(Int_t i, const char* text) # gStyle.SetHeaderPS(const char* header) # gStyle.SetTitlePS(const char* pstitle) #gStyle.SetColorModelPS(1) # gStyle.SetBarOffset(Float_t baroff = 0.5) # gStyle.SetBarWidth(Float_t barwidth = 0.5) # gStyle.SetPaintTextFormat(const char* format = "g") # gStyle.SetPalette(Int_t ncolors = 0, Int_t* colors = 0) # gStyle.SetTimeOffset(Double_t toffset) # gStyle.SetHistMinimumZero(kTRUE) #gStyle.cd() print "TDR Style initialized"
def initialization(batch=True, font=default_font): '''-- ROOT initialization --''' print "Initializing ROOT ..." # general gROOT.Reset() gROOT.SetBatch(batch) gROOT.SetStyle("Plain") # gStyle gStyle.SetFillColor(0) gStyle.SetCanvasColor(10) gStyle.SetLineWidth(1) gStyle.SetPalette(8) gStyle.SetTextFont(font) #gStyle.SetTextSize(30) # Frame gStyle.SetFrameBorderMode(0) gStyle.SetFrameFillColor(0) # Pad gStyle.SetPadBorderMode(0) gStyle.SetPadColor(0) gStyle.SetPadBottomMargin(0.1) gStyle.SetPadTopMargin(0.01) gStyle.SetPadLeftMargin(0.1) gStyle.SetPadRightMargin(0.01) gStyle.SetPadTickX(1) # make ticks be on all 4 sides. gStyle.SetPadTickY(1) gStyle.SetPadGridX(0) gStyle.SetPadGridY(0) # histogram gStyle.SetHistFillStyle(0) gStyle.SetOptTitle(0) gStyle.SetTitleSize(0.22) gStyle.SetTitleFontSize(10) gStyle.SetTitleFont(font) gStyle.SetTitleFont(font, "xyz") gStyle.SetTitleYOffset(1.0) gStyle.SetTitleXOffset(1.0) gStyle.SetTitleXSize(0.04) gStyle.SetTitleYSize(0.04) gStyle.SetTitleX(.15) gStyle.SetTitleY(.98) gStyle.SetTitleW(.70) gStyle.SetTitleH(.05) # statistics box gStyle.SetOptStat(0) gStyle.SetStatFont(font) gStyle.SetStatFontSize(10) gStyle.SetStatX(.91) gStyle.SetStatY(.90) gStyle.SetStatW(.15) gStyle.SetStatH(.15) # axis labels gStyle.SetLabelFont(font) gStyle.SetLabelFont(font, "xyz") gStyle.SetLabelSize(10, "xyz") # gStyle.SetGridColor(1) gStyle.SetLegendBorderSize(1)
def initialize(fitresults=True, grid=False): gROOT.SetStyle("Plain") gStyle.SetOptFit() gStyle.SetOptStat(0) # For the canvas: gStyle.SetCanvasBorderMode(0) gStyle.SetCanvasColor(kWhite) gStyle.SetCanvasDefH(600) #Height of canvas gStyle.SetCanvasDefW(600) #Width of canvas gStyle.SetCanvasDefX(0) #POsition on screen gStyle.SetCanvasDefY(0) # For the Pad: gStyle.SetPadBorderMode(0) gStyle.SetPadColor(kWhite) gStyle.SetPadGridX(False) gStyle.SetPadGridY(False) gStyle.SetGridColor(0) gStyle.SetGridStyle(3) gStyle.SetGridWidth(1) # For the frame: gStyle.SetFrameBorderMode(0) gStyle.SetFrameBorderSize(1) gStyle.SetFrameFillColor(kWhite) gStyle.SetFrameFillStyle(1000) gStyle.SetFrameLineColor(1) gStyle.SetFrameLineStyle(1) gStyle.SetFrameLineWidth(1) # For the histo: gStyle.SetHistLineColor(1) gStyle.SetHistLineStyle(0) gStyle.SetHistLineWidth(2) gStyle.SetEndErrorSize(2) gStyle.SetErrorX(0.) gStyle.SetMarkerStyle(20) #For the fit/function: gStyle.SetOptFit(1) gStyle.SetFitFormat("5.4g") gStyle.SetFuncColor(2) gStyle.SetFuncStyle(1) gStyle.SetFuncWidth(1) #For the date: gStyle.SetOptDate(0) # For the statistics box: gStyle.SetOptFile(0) gStyle.SetOptStat(0) # To display the mean and RMS: SetOptStat("mr") gStyle.SetStatColor(kWhite) gStyle.SetStatFont(42) gStyle.SetStatFontSize(0.025) gStyle.SetStatTextColor(1) gStyle.SetStatFormat("6.4g") gStyle.SetStatBorderSize(1) gStyle.SetStatH(0.1) gStyle.SetStatW(0.15) # Margins: gStyle.SetPadTopMargin(0.05) gStyle.SetPadLeftMargin(0.16) gStyle.SetPadRightMargin(0.04) # top group adaption, original is 0.02 gStyle.SetPadBottomMargin(0.13) # For the Global title: gStyle.SetOptTitle(0) gStyle.SetTitleFont(42) gStyle.SetTitleColor(1) gStyle.SetTitleTextColor(1) gStyle.SetTitleFillColor(10) gStyle.SetTitleFontSize(0.05) # For the axis titles: gStyle.SetTitleColor(1, "XYZ") gStyle.SetTitleFont(42, "XYZ") gStyle.SetTitleSize(0.06, "XYZ") gStyle.SetTitleXOffset(0.9) gStyle.SetTitleYOffset(1.25) # For the axis labels: gStyle.SetLabelColor(1, "XYZ") gStyle.SetLabelFont(42, "XYZ") gStyle.SetLabelOffset(0.007, "XYZ") gStyle.SetLabelSize(0.05, "XYZ") #gStyle.SetLabelSize(0.04, "XYZ") # For the axis: gStyle.SetAxisColor(1, "XYZ") gStyle.SetStripDecimals(True) gStyle.SetTickLength(0.03, "XYZ") gStyle.SetNdivisions(510, "XYZ") gStyle.SetPadTickX(1) # To get tick marks on the opposite side of the frame gStyle.SetPadTickY(1) # Change for log plots: gStyle.SetOptLogx(0) gStyle.SetOptLogy(0) gStyle.SetOptLogz(0) gStyle.SetPalette(1) #(1,0) # another top group addition gStyle.SetHatchesSpacing(1.0) # Postscript options: gStyle.SetPaperSize(20., 20.) # For graphs gStyle.SetErrorX(0) # suppress error along x if grid: gStyle.SetPadGridX(gridOn) gStyle.SetPadGridY(gridOn) gStyle.SetGridColor(kGray)
def tdrstyle(): gROOT.SetStyle("Plain") gStyle.SetAxisColor(1, "XYZ") gStyle.SetCanvasColor(0) #gStyle.SetCanvasBorderSize(10) gStyle.SetCanvasBorderMode(0) gStyle.SetCanvasDefH(700) gStyle.SetCanvasDefW(700) gStyle.SetCanvasDefX(0) gStyle.SetCanvasDefY(0) gStyle.SetFitFormat("5.4g") gStyle.SetFuncColor(2) gStyle.SetFuncStyle(1) gStyle.SetFuncWidth(1) gStyle.SetFrameBorderMode(0) gStyle.SetFrameBorderSize(1) gStyle.SetFrameFillStyle(0) gStyle.SetFrameFillColor(0) gStyle.SetFrameLineColor(1) gStyle.SetFrameLineStyle(1) # 0? gStyle.SetFrameLineWidth(1) # 1? gStyle.SetGridColor(0) gStyle.SetGridStyle(3) gStyle.SetGridWidth(1) #gStyle.SetHistFillColor(1) #gStyle.SetHistFillStyle(0) gStyle.SetHistLineColor(1) gStyle.SetHistLineStyle(0) gStyle.SetHistLineWidth(1) gStyle.SetLabelColor(1, "XYZ") gStyle.SetLabelFont(42,"XYZ") gStyle.SetLabelOffset(0.007,"XYZ") # 0.010? gStyle.SetLabelSize(0.05,"XYZ") # 0.04? gStyle.SetLegendBorderSize(0) gStyle.SetLegendFillColor(0) gStyle.SetLegendFont(42) gStyle.SetMarkerSize(1.0) gStyle.SetMarkerStyle(20) gStyle.SetLineColor(1) gStyle.SetLineWidth(2) #gStyle.SetLineScalePS(2) gStyle.SetOptDate(0) gStyle.SetOptFile(0) gStyle.SetOptFit(1) gStyle.SetOptStat(0) gStyle.SetOptTitle(0) #gStyle.SetOptLogx(0) #gStyle.SetOptLogy(0) #gStyle.SetOptLogz(0) gStyle.SetPadColor(0) gStyle.SetPadBorderMode(0) gStyle.SetPadBorderSize(10) gStyle.SetPadTopMargin(0.05) # 0.08? gStyle.SetPadBottomMargin(0.13) gStyle.SetPadLeftMargin(0.16) gStyle.SetPadRightMargin(0.03) # 0.05? gStyle.SetPadGridX(0) gStyle.SetPadGridY(0) gStyle.SetPadTickX(1) gStyle.SetPadTickY(1) gStyle.SetStatColor(0) gStyle.SetStatFont(42) gStyle.SetStatFontSize(0.025) gStyle.SetStatTextColor(1) gStyle.SetStatFormat("6.4g") gStyle.SetStatBorderSize(1) gStyle.SetStatH(0.1) gStyle.SetStatW(0.15) #gStyle.SetStatX(0) #gStyle.SetStatY(0) #gStyle.SetTextSize(0.055) gStyle.SetTextFont(42) gStyle.SetTitleBorderSize(0) gStyle.SetTitleColor(1) gStyle.SetTitleFont(42) gStyle.SetTitleColor(1,"XYZ") gStyle.SetTitleFont(42,"XYZ") gStyle.SetTitleSize(0.06,"XYZ") # 0.05? #gStyle.SetTitleOffset(1.4,"XYZ") gStyle.SetTitleOffset(0.9,"X") gStyle.SetTitleOffset(1.20,"Y") gStyle.SetTitleFillColor(10) gStyle.SetTitleFontSize(0.05) gStyle.SetTitleTextColor(1) #gStyle.SetTitleH(0) #gStyle.SetTitleW(0) #gStyle.SetTitleX(0) #gStyle.SetTitleY(0.985) #gStyle.SetTitleStyle(1001) gStyle.SetPalette(1) #gStyle.SetNdivisions(510, "XYZ") # 505? gStyle.SetNdivisions(505, "XYZ") gStyle.SetEndErrorSize(2) # 2? #gStyle.SetErrorMarker(20) #gStyle.SetErrorX(0.) #gStyle.SetPaperSize(20.,20.) gStyle.SetStripDecimals(1) gStyle.SetTickLength(0.03, "XYZ") return 1
def setStyle(): gStyle.SetPadBorderMode(0) gStyle.SetFrameBorderMode(0) gStyle.SetPadBottomMargin(0.12) gStyle.SetPadLeftMargin(0.12) gStyle.SetCanvasColor(ROOT.kWhite) gStyle.SetCanvasDefH(600) #Height of canvas gStyle.SetCanvasDefW(600) #Width of canvas gStyle.SetCanvasDefX(0) #POsition on screen gStyle.SetCanvasDefY(0) gStyle.SetPadTopMargin(0.05) gStyle.SetPadBottomMargin(0.15) #0.13); gStyle.SetPadLeftMargin(0.15) #0.16); gStyle.SetPadRightMargin(0.05) #0.02); # For the Pad: gStyle.SetPadBorderMode(0) # gStyle.SetPadBorderSize(Width_t size = 1); gStyle.SetPadColor(ROOT.kWhite) gStyle.SetPadGridX(ROOT.kFALSE) gStyle.SetPadGridY(ROOT.kFALSE) gStyle.SetGridColor(0) gStyle.SetGridStyle(3) gStyle.SetGridWidth(1) # For the frame: gStyle.SetFrameBorderMode(0) gStyle.SetFrameBorderSize(1) gStyle.SetFrameFillColor(0) gStyle.SetFrameFillStyle(0) gStyle.SetFrameLineColor(1) gStyle.SetFrameLineStyle(1) gStyle.SetFrameLineWidth(1) gStyle.SetAxisColor(1, "XYZ") gStyle.SetStripDecimals(ROOT.kTRUE) gStyle.SetTickLength(0.03, "XYZ") gStyle.SetNdivisions(505, "XYZ") gStyle.SetPadTickX(1) # To get tick marks on the opposite side of the frame gStyle.SetPadTickY(1) gStyle.SetGridColor(0) gStyle.SetGridStyle(3) gStyle.SetGridWidth(1) gStyle.SetTitleColor(1, "XYZ") gStyle.SetTitleFont(42, "XYZ") gStyle.SetTitleSize(0.05, "XYZ") # gStyle.SetTitleXSize(Float_t size = 0.02); # Another way to set the size? # gStyle.SetTitleYSize(Float_t size = 0.02); gStyle.SetTitleXOffset(1.15) #0.9); gStyle.SetTitleYOffset(1.3) # => 1.15 if exponents gStyle.SetLabelColor(1, "XYZ") gStyle.SetLabelFont(42, "XYZ") gStyle.SetLabelOffset(0.007, "XYZ") gStyle.SetLabelSize(0.045, "XYZ") gStyle.SetPadBorderMode(0) gStyle.SetFrameBorderMode(0) gStyle.SetTitleTextColor(1) gStyle.SetTitleFillColor(10) gStyle.SetTitleFontSize(0.05)
def CLICdpStyle(): gROOT.SetStyle("Plain") gStyle.SetCanvasColor(root.kWhite) gStyle.SetFrameFillColor(root.kWhite) gStyle.SetStatColor(root.kWhite) gStyle.SetPadColor(root.kWhite) gStyle.SetFillColor(10) gStyle.SetTitleFillColor(root.kWhite) gStyle.SetPaperSize(20, 26) gStyle.SetDrawBorder(0) gStyle.SetCanvasBorderMode(0) gStyle.SetPadBorderMode(0) gStyle.SetFrameBorderMode(0) gStyle.SetLegendBorderSize(0) gStyle.SetTextSize(0.05) gStyle.SetTitleSize(0.06, "xyz") gStyle.SetLabelSize(0.06, "xyz") gStyle.SetLabelOffset(0.015, "xyz") gStyle.SetTitleOffset(1.2, "yz") gStyle.SetTitleOffset(1.17, "x") font = 42 gStyle.SetTitleFont(font) gStyle.SetTitleFontSize(0.06) gStyle.SetStatFont(font) gStyle.SetStatFontSize(0.07) gStyle.SetTextFont(font) gStyle.SetLabelFont(font, "xyz") gStyle.SetTitleFont(font, "xyz") gStyle.SetTitleBorderSize(0) gStyle.SetStatBorderSize(1) gStyle.SetMarkerStyle(1) gStyle.SetLineWidth(2) gStyle.SetMarkerSize(1.2) gStyle.SetPalette(1) gStyle.SetOptTitle(0) gStyle.SetOptStat(0) gStyle.SetOptFit(0) gStyle.SetEndErrorSize(5) gStyle.SetHistLineWidth(2) gStyle.SetFrameLineWidth(2) gStyle.SetFuncWidth(2) gStyle.SetHistLineColor(root.kBlack) gStyle.SetFuncColor(root.kBlack) gStyle.SetLabelColor(root.kBlack, "xyz") gStyle.SetPadBottomMargin(0.18) gStyle.SetPadTopMargin(0.11) gStyle.SetPadRightMargin(0.08) gStyle.SetPadLeftMargin(0.17) gStyle.SetNdivisions(506, "xy") gStyle.SetPadGridX(0) gStyle.SetPadGridY(0) gStyle.SetPadTickX(1) gStyle.SetPadTickY(1) gStyle.SetCanvasDefW(800) gStyle.SetCanvasDefH(700) gROOT.ForceStyle()
def setStyle(): TColor.InitializeColors() stops = array('d', [ 0.0000, 0.1250, 0.2500, 0.3750, 0.5000, 0.6250, 0.7500, 0.8750, 1.0000 ]) red = array('d', [ 0.9764, 0.9956, 0.8186, 0.5301, 0.1802, 0.0232, 0.0780, 0.0592, 0.2082 ]) green = array('d', [ 0.9832, 0.7862, 0.7328, 0.7492, 0.7178, 0.6419, 0.5041, 0.3599, 0.1664 ]) blue = array('d', [ 0.0539, 0.1968, 0.3499, 0.4662, 0.6425, 0.7914, 0.8385, 0.8684, 0.5293 ]) TColor.CreateGradientColorTable(9, stops, red, green, blue, 255, 1.0) gStyle.SetHatchesLineWidth(1) gStyle.SetNumberContours(255) gStyle.SetNdivisions(505, "xyz") gStyle.SetTitleBorderSize(0) gStyle.SetTitleColor(1) gStyle.SetTitleStyle(3013) gStyle.SetTitleFillColor(0) gStyle.SetTitleX(0.05) gStyle.SetTitleW(0.4) gStyle.SetTitleY(0.965) gStyle.SetTitleH(0.065) gStyle.SetCanvasBorderMode(0) gStyle.SetCanvasBorderSize(3) gStyle.SetCanvasColor(0) gStyle.SetPadColor(0) gStyle.SetPadBorderMode(0) gStyle.SetFuncWidth(3) gStyle.SetPadGridY(False) gStyle.SetPadGridX(False) gStyle.SetFrameLineWidth(1) gStyle.SetMarkerSize(5) gStyle.SetPadTickX(True) gStyle.SetPadTickY(True) #gStyle.SetPalette(1) gStyle.SetHistLineWidth(3) gStyle.SetHistLineColor(1) gStyle.SetOptStat(0) gStyle.SetOptFit(0) gStyle.SetStatW(0.25) gStyle.SetStatH(0.25) gStyle.SetStatX(0.9) gStyle.SetStatY(0.9) gStyle.SetStatColor(0) gStyle.SetStatFormat("6.4g") gStyle.SetPadTopMargin(0.05) gStyle.SetPadRightMargin(0.05) gStyle.SetPadBottomMargin(0.16) gStyle.SetPadLeftMargin(0.12) font = 42 gStyle.SetTextSize(.055) gStyle.SetTextFont(font) gStyle.SetLabelFont(font, "x") gStyle.SetTitleFont(font, "x") gStyle.SetLabelFont(font, "y") gStyle.SetTitleFont(font, "y") gStyle.SetLabelFont(font, "z") gStyle.SetTitleFont(font, "z") gStyle.SetTitleSize(.055, "x") gStyle.SetTitleSize(.055, "y") gStyle.SetTitleSize(.05, "z") gStyle.SetLabelSize(.05, "x") gStyle.SetLabelSize(.05, "y") gStyle.SetLabelSize(.05, "z") gStyle.SetLabelOffset(0.014, "x") gStyle.SetLabelOffset(0.006, "y") gStyle.SetLabelOffset(0.008, "z") gStyle.SetTitleOffset(1, "y") gStyle.SetTitleXOffset(1.2) # use bold lines and markers gStyle.SetMarkerStyle(20) gStyle.SetMarkerColor(1) gStyle.SetMarkerSize(1.2) gStyle.SetLineStyleString(2, "[12 12]") # postscript dashes gStyle.SetPadTickX(1) gStyle.SetPadTickY(1)
def rocPlotMacro(): # load TDR-style plotting macro gROOT.LoadMacro("$CMSSW_BASE/src/TauAnalysisTools/TauAnalysisTools/macros/tdrstyle.C") ROOT.setTDRStyle() gStyle.SetFrameLineWidth(3) gStyle.SetLineWidth(3) gStyle.SetPadGridX(True) gStyle.SetPadGridY(True) gStyle.SetPadTopMargin(0.08) gStyle.SetPadBottomMargin(0.15) gStyle.SetPadLeftMargin(0.18) gStyle.SetPadRightMargin(0.05) gStyle.SetTitleFontSize(0.055) gStyle.SetTitleSize(0.055, "XYZ") gStyle.SetTitleXOffset(1.25) gStyle.SetTitleYOffset(1.60) gStyle.SetLabelSize(0.04, "XYZ") gStyle.SetLabelOffset(0.013, "XYZ") # list of trainings reference53X = { 'folder' : 'forFabio', 'color' : ROOT.kGreen, 'text' : '53X' } reference74X = { 'folder' : 'antiElectronDiscr74X_onlyZWTTjetsHiggsWZprimeSUSY_FullSkim', 'color' : ROOT.kMagenta, 'text' : '74X (Complete skim)' } inputFilePath = '/nfs/dust/cms/user/fcolombo/HiggsToTauTau/TauPOG/antiElectronDiscrMVATraining' trainingList = [] trainingList.append(reference53X) trainingList.append(reference74X) # list of plots to produce roc_linear = { 'file' : 'showROCcurvesAntiElectronDiscrMVA_all_linear.root', 'name' : 'roc_linear', 'y_range' : [0.4, 1.], 'y_log' : False, 'leg_loc' : [0.2, 0.2, 0.8, 0.35] } roc_log = { 'file' : 'showROCcurvesAntiElectronDiscrMVA_all_log.root', 'name' : 'roc_log', 'y_range' : [0.001, 1.], 'y_log' : True, 'leg_loc' : [0.2, 0.75, 0.8, 0.9] } plotList = [] plotList.append(roc_linear) plotList.append(roc_log) pTbinsList = ['','tauPtLt50_','tauPt50to100_','tauPt100to200_','tauPt200to400_','tauPt400to600_','tauPt600to900_','tauPt900to1200_','tauPtGt1200_'] for iPlot, plotDict in enumerate(plotList): for ptBin in pTbinsList: filename = 'showROCcurvesAntiElectronDiscrMVA_all_'+ptBin+('log' if plotDict['y_log'] else 'linear') c1 = TCanvas() c1.SetTitle(plotDict['name']) legend = TLegend(plotDict['leg_loc'][0], plotDict['leg_loc'][1], plotDict['leg_loc'][2], plotDict['leg_loc'][3]) legend.SetShadowColor(0) legend.SetFillColor(0) for iTrain, trainDict in enumerate(trainingList): file = TFile.Open(os.path.join(inputFilePath, trainDict['folder'], filename+'.root')) canvas = file.Get("canvas") histo = canvas.GetPrimitive("dummyHistogram") graph = canvas.GetPrimitive("mvaAntiElectronDiscr5_TestTree_"+ptBin+"cloned") legend.AddEntry(graph, trainDict['text'], 'l') c1.cd() if (iTrain == 0): histo.GetYaxis().SetRangeUser(plotDict['y_range'][0], plotDict['y_range'][1]) histo.GetYaxis().SetTitleOffset(1.6) histo.Draw() graph.SetMarkerColor(trainDict['color']) graph.SetLineColor(trainDict['color']) graph.SetLineWidth(2) graph.Draw("LP SAME") if (plotDict['y_log'] == True): c1.SetLogy() legend.Draw() if 'plots' not in os.listdir(inputFilePath): os.mkdir(os.path.join(inputFilePath, 'plots')) c1.SaveAs(os.path.join(inputFilePath, 'plots', plotDict['name']+'_'+(ptBin[:-1] if ptBin != '' else 'all')+'.png'))
hname2026_f = lambda hname: "emtf2026_" + hname[5:] donotdelete = [] infile = "histos_tbc_omtf_add.27.root" # ______________________________________________________________________________ if __name__ == '__main__': from ROOT import gROOT, gPad, gStyle, TFile, TCanvas, TH1F, TH2F, TPolyLine, TLatex, TColor, TEfficiency, TLine, TLatex, TGraph, TGraphAsymmErrors # ____________________________________________________________________________ # Setup basic drawer gROOT.LoadMacro("tdrstyle.C") gROOT.ProcessLine("setTDRStyle();") #gROOT.SetBatch(True) gStyle.SetPadGridX(True) gStyle.SetPadGridY(True) gStyle.SetMarkerStyle(1) gStyle.SetEndErrorSize(0) gROOT.ForceStyle() tline = TLine() tline.SetLineColor(920 + 2) # kGray+2 tline.SetLineStyle(2) tlatexCMS1 = TLatex() tlatexCMS1.SetNDC() tlatexCMS1.SetTextFont(61) tlatexCMS1.SetTextSize(0.75 * 0.05) tlatexCMS2 = TLatex()
def SED(flist): gStyle.SetOptLogx() gStyle.SetOptLogy() gStyle.SetPadGridX(True) gStyle.SetPadGridY(True) gStyle.SetEndErrorSize(10) l = TLegend(.65, .6, .96, .95) g = [] gUL = [] pubdir = "/home/smasuda/storage/.Fermi2/Data/DataPoint/GammaCygni/" # g.append(GetPubData(pubdir+"GCyg_FermiLande_data.csv", # pubdir+"GCyg_FermiLande_error.csv")) # g[-1].SetName('gLande12') # g[-1].SetLineColor(kCyan) # g[-1].SetMarkerColor(g[-1].GetLineColor()) # g[-1].SetMarkerStyle(21) # gUL.append(TGraph(0)) # l.AddEntry(g[-1],'Lande+ \'12','p') g.append( GetPubData(pubdir + "GCyg_FermiFraija_data.csv", pubdir + "GCyg_FermiFraija_error.csv")) g[-1].SetName('gFraija16') g[-1].SetLineColor(kPink + 1) g[-1].SetLineColor(kCyan) g[-1].SetMarkerColor(g[-1].GetLineColor()) g[-1].SetMarkerStyle(22) gUL1 = GetPubData(pubdir + "GCyg_FermiFraija_UL.csv") gUL1.SetName('gFraija16UL') gUL1.SetLineColor(g[-1].GetLineColor()) gUL1.SetMarkerColor(g[-1].GetLineColor()) gUL.append(gUL1) l.AddEntry(g[-1], 'Fraija+ \'16', 'p') # g.append(GetPubData(pubdir+"GCyg_MAGIC_data.csv", # pubdir+"GCyg_MAGIC_error.csv")) # g[-1].SetLineColor(kMagenta) # g[-1].SetMarkerColor(kMagenta) # g[-1].SetMarkerStyle(29) # gUL.append(TGraph(0)) def ConvertFluxUnit(glist): g = glist[-1] n = g.GetN() x = g.GetX() y = g.GetY() ey = g.GetEY() for i in range(n): y[i] *= x[i] * x[i] * 1e-6 * 1e-4 if g.ClassName() == "TGraphErrors": ey[i] *= x[i] * x[i] * 1e-6 * 1e-4 rfile = TFile( "/home/smasuda/storage/Fermi/Data/GammaCygni2017/VERJ2019p407_spec.root" ) gVER = rfile.Get("gVER") gVERUL = rfile.Get("gVERUL") fVER = rfile.Get("fVER") rfile.Close() g.append(gVER) gUL.append(gVERUL) fVER.SetParameter(0, fVER.GetParameter(0) * 1e-4) fVER.SetParameter(1, fVER.GetParameter(1) - 2.) ConvertFluxUnit(g) ConvertFluxUnit(gUL) colV = kGreen gVER.SetMarkerColor(colV) gVER.SetLineColor(colV) gVERUL.SetMarkerColor(colV) gVERUL.SetLineColor(colV) fVER.SetLineColor(colV) l.AddEntry(g[-1], 'VER J2019+407', 'p') rfile = TFile( '/home/smasuda/storage/MAGIC/GammaCygni2017_ST7/analysis/flute/CombAll/Unfolding_Output_combunfold_2-Tikhonov.root' ) g.append(rfile.Get("fGraph1E2")) rfile.Close() g[-1].SetMarkerStyle(21) g[-1].SetMarkerColor(kMagenta + 1) g[-1].SetLineColor(g[-1].GetMarkerColor()) gUL.append(TGraph(0)) l.AddEntry(g[-1], 'MAGIC this work', 'lp') rfile = TFile( "/home/smasuda/storage/Fermi/Data/GammaCygni2017/MarcelFermi.root") gtmp = [] for key in rfile.GetListOfKeys(): obj = key.ReadObj() if obj.InheritsFrom(TGraph.Class()): gtmp.append(obj) # g.append(gtmp[0]) # gUL.append(TGraph(0)) # g.append(gtmp[1]) # gUL.append(TGraph(0)) # l.AddEntry(g[-1],'Marcel disk','lp') # g.append(gtmp[2]) # gUL.append(gtmp[3]) # l.AddEntry(g[-1],'Marcel gaus','lp') # g.append(TGraph(0)) # gUL.append(gtmp[4]) # l.AddEntry(gUL[-1],'Marcel arc','lp') # arr1=rfile.Get("aGausUL") # arr2=rfile.Get("aArcUL") rfile.Close() # XX=np.array([1.]) # YY=np.array([1.e-10]) # g.append(TGraph(1,XX,YY)) # gUL.append(TGraph(0)) for f in flist: tmpg, tmpgUL = GetData(f.file, f.scale, title=f.title) tmpg.SetLineColor(f.col) tmpg.SetMarkerColor(f.col) tmpg.SetMarkerStyle(f.sty) tmpgUL.SetLineColor(f.col) if f.leg != '': l.AddEntry(tmpg, f.leg, 'p') g.append(tmpg) gUL.append(tmpgUL) # l.AddEntry('p') ng = len(g) mg = TMultiGraph() for i in range(ng): if g[i].GetName() == 'gLP': mg.Add(g[i], '3') else: mg.Add(g[i], 'pz') if gUL[i].GetN() > 0: if gUL[i].GetName() == 'gGausUL' or gUL[i].GetName() == 'gArcUL': mg.Add(gUL[i], 'pz') else: mg.Add(gUL[i], 'p') xbin = np.logspace(np.log10(0.9), np.log10(8079.765852892145), 101) # ybin=np.logspace(np.log10(1.565210892602076e-14),np.log10(1.675199606589398e-10),101) ybin = np.logspace(np.log10(3.786556805899183e-14), np.log10(1.05e-10), 101) frame = TH2F("frame", "SED;Energy [GeV];E^{2}dN/dE [TeV cm^{-2} s^{-1}]", 100, xbin, 100, ybin) frame.SetStats(False) frame.SetDirectory(0) frame.Draw("0") mg.SetTitle("SED;Energy [GeV];E^{2}dN/dE [TeV cm^{-2} s^{-1}]") mg.Draw() fVER.Draw("same") arr = [] for i in range(len(gUL)): if gUL[i].GetN() > 0: arr.append(DrawUL(gUL[i])) # arr.append(arr1) # arr.append(arr2) # arr1.Draw() # arr2.Draw() l.Draw() gROOT.frame = frame gROOT.mg = mg gROOT.arr = arr gROOT.l = l gROOT.fVER = fVER gStyle.SetOptLogx(False) gStyle.SetOptLogy(False)
def setTDRStyle(force): gStyle.SetCanvasBorderMode(0) gStyle.SetCanvasColor(kWhite) gStyle.SetCanvasDefH(600) gStyle.SetCanvasDefW(600) gStyle.SetCanvasDefX(0) gStyle.SetCanvasDefY(0) gStyle.SetPadBorderMode(0) gStyle.SetPadColor(kWhite) gStyle.SetPadGridX(False) gStyle.SetPadGridY(False) gStyle.SetGridColor(0) gStyle.SetGridStyle(3) gStyle.SetGridWidth(1) gStyle.SetFrameBorderMode(0) gStyle.SetFrameBorderSize(1) gStyle.SetFrameFillColor(0) gStyle.SetFrameFillStyle(0) gStyle.SetFrameLineColor(1) gStyle.SetFrameLineStyle(1) gStyle.SetFrameLineWidth(1) if force: gStyle.SetHistLineColor(1) gStyle.SetHistLineStyle(0) gStyle.SetHistLineWidth(1) gStyle.SetEndErrorSize(2) gStyle.SetErrorX(0.) gStyle.SetMarkerStyle(20) gStyle.SetOptFit(1) gStyle.SetFitFormat("5.4g") gStyle.SetFuncColor(2) gStyle.SetFuncStyle(1) gStyle.SetFuncWidth(1) gStyle.SetOptDate(0) gStyle.SetOptFile(0) gStyle.SetOptStat(0) gStyle.SetStatColor(kWhite) gStyle.SetStatFont(42) gStyle.SetStatFontSize(0.04) gStyle.SetStatTextColor(1) gStyle.SetStatFormat("6.4g") gStyle.SetStatBorderSize(1) gStyle.SetStatH(0.1) gStyle.SetStatW(0.2) gStyle.SetPadTopMargin(0.05) gStyle.SetPadBottomMargin(0.13) gStyle.SetPadLeftMargin(0.16) gStyle.SetPadRightMargin(0.04) gStyle.SetOptTitle(0) gStyle.SetTitleFont(42) gStyle.SetTitleColor(1) gStyle.SetTitleTextColor(1) gStyle.SetTitleFillColor(10) gStyle.SetTitleFontSize(0.05) gStyle.SetTitleColor(1, "XYZ") gStyle.SetTitleFont(42, "XYZ") gStyle.SetTitleSize(0.06, "XYZ") gStyle.SetTitleXOffset(0.9) gStyle.SetTitleYOffset(1.25) gStyle.SetLabelColor(1, "XYZ") gStyle.SetLabelFont(42, "XYZ") gStyle.SetLabelOffset(0.007, "XYZ") gStyle.SetLabelSize(0.05, "XYZ") gStyle.SetAxisColor(1, "XYZ") gStyle.SetStripDecimals(True) gStyle.SetTickLength(0.03, "XYZ") gStyle.SetNdivisions(510, "XYZ") gStyle.SetPadTickX(1) gStyle.SetPadTickY(1) gStyle.SetOptLogx(0) gStyle.SetOptLogy(0) gStyle.SetOptLogz(0) gStyle.SetPaperSize(20.,20.) gROOT.ForceStyle()
def cebefo_style(): #TStyle *gStyle = new TStyle("gStyle","gStyle"); #our settings, maybe in the future we could create a more personal style gStyle.SetPadTickX(1) gStyle.SetPadTickY(1) gStyle.SetHistLineWidth(3) gStyle.SetMarkerStyle(1) gStyle.SetTextSize(0.065) gStyle.SetOptFit(1111) # axis gStyle.SetTitleSize(.05, "X") #.055 gStyle.SetTitleOffset(1.1, "X") #1.2,0.9 #gStyle.SetLabelOffset(0.003,"X"); gStyle.SetLabelSize(.05, "X") #gStyle.SetLabelFont(42,"X"); gStyle.SetTitleSize(.05, "Y") #.055 gStyle.SetTitleOffset(1.1, "Y") #gStyle.SetLabelOffset(0.008,"Y"); gStyle.SetLabelSize(.05, "Y") #gStyle.SetLabelFont(42,"Y"); gStyle.SetPadLeftMargin(.16) gStyle.SetPadBottomMargin(.12) gStyle.SetTitleSize(.05, "Z") gStyle.SetTitleOffset(1.1, "Z") #gStyle.SetLabelOffset(0.008,"Z"); gStyle.SetLabelSize(0.05, "Z") #gStyle.SetLabelFont(42,"Z"); # gStyle.SetLegendTextSize(0.04); #gStyle.SetStatFontSize(0.2); #histograms properties gStyle.SetOptStat(112210) #gStyle.SetStripDecimals(False) #gStyle.SetLineStyleString(11,"20 10") # canvas #gStyle.SetCanvasColor(0); #gStyle.SetCanvasBorderSize(10); #gStyle.SetCanvasBorderMode(0); #gStyle.SetCanvasDefW(600); #gStyle.SetCanvasDefH(600); # pads # gStyle.SetPadColor(0); # gStyle.SetPadBorderSize(10); # gStyle.SetPadBorderMode(0); gStyle.SetPadLeftMargin(.12) gStyle.SetPadRightMargin(.02) gStyle.SetPadBottomMargin(.12) gStyle.SetPadTopMargin(.07) gStyle.SetPadGridX(1) gStyle.SetPadGridY(1)
def initialize2(self): # For the canvas: gStyle.SetCanvasBorderMode(0) gStyle.SetCanvasColor(kWhite) gStyle.SetCanvasDefH(600) #Height of canvas gStyle.SetCanvasDefW(600) #Width of canvas gStyle.SetCanvasDefX(0) #POsition on screen gStyle.SetCanvasDefY(0) # For the Pad: gStyle.SetPadBorderMode(0) # gStyle.SetPadBorderSize(Width_t size = 1) gStyle.SetPadColor(kWhite) gStyle.SetPadGridX(False) gStyle.SetPadGridY(False) gStyle.SetGridColor(0) gStyle.SetGridStyle(3) gStyle.SetGridWidth(1) # For the frame: gStyle.SetFrameBorderMode(0) gStyle.SetFrameBorderSize(1) gStyle.SetFrameFillStyle(1000) gStyle.SetFrameFillColor(0) gStyle.SetFrameFillStyle(0) gStyle.SetFrameLineColor(1) gStyle.SetFrameLineStyle(1) gStyle.SetFrameLineWidth(1) # For the histo: # gStyle.SetHistFillColor(1) # gStyle.SetHistFillStyle(0) gStyle.SetHistLineColor(1) gStyle.SetHistLineStyle(0) gStyle.SetHistLineWidth(1) # gStyle.SetLegoInnerR(Float_t rad = 0.5) # gStyle.SetNumberContours(Int_t number = 20) gStyle.SetEndErrorSize(2) # gStyle.SetErrorMarker(20) gStyle.SetErrorX(0.) gStyle.SetMarkerStyle(20) #For the fit/function: gStyle.SetOptFit(1) gStyle.SetFitFormat("5.4g") gStyle.SetFuncColor(2) gStyle.SetFuncStyle(1) gStyle.SetFuncWidth(1) #For the date: gStyle.SetOptDate(0) # gStyle.SetDateX(Float_t x = 0.01) # gStyle.SetDateY(Float_t y = 0.01) # For the statistics box: gStyle.SetOptFile(0) gStyle.SetOptStat( 0) # To display the mean and RMS: SetOptStat("mr") gStyle.SetStatColor(kWhite) gStyle.SetStatFont(42) gStyle.SetStatFontSize(0.025) gStyle.SetStatTextColor(1) gStyle.SetStatFormat("6.4g") gStyle.SetStatBorderSize(1) gStyle.SetStatH(0.1) gStyle.SetStatW(0.15) # gStyle.SetStatStyle(Style_t style = 1001) # gStyle.SetStatX(Float_t x = 0) # gStyle.SetStatY(Float_t y = 0) # Margins: gStyle.SetPadTopMargin(0.05) gStyle.SetPadBottomMargin(0.13) gStyle.SetPadLeftMargin(0.16) gStyle.SetPadRightMargin(0.02) # For the Global title: gStyle.SetOptTitle(0) gStyle.SetTitleFont(42) gStyle.SetTitleColor(1) gStyle.SetTitleTextColor(1) gStyle.SetTitleFillColor(10) gStyle.SetTitleFontSize(0.05) # gStyle.SetTitleH(0) # Set the height of the title box # gStyle.SetTitleW(0) # Set the width of the title box # gStyle.SetTitleX(0) # Set the position of the title box # gStyle.SetTitleY(0.985) # Set the position of the title box # gStyle.SetTitleStyle(Style_t style = 1001) # gStyle.SetTitleBorderSize(2) # For the axis titles: gStyle.SetTitleColor(1, "XYZ") gStyle.SetTitleFont(42, "XYZ") gStyle.SetTitleSize(0.06, "XYZ") # gStyle.SetTitleXSize(Float_t size = 0.02) # Another way to set the size? # gStyle.SetTitleYSize(Float_t size = 0.02) gStyle.SetTitleXOffset(0.9) gStyle.SetTitleYOffset(1.25) # gStyle.SetTitleOffset(1.1, "Y") # Another way to set the Offset # For the axis labels: gStyle.SetLabelColor(1, "XYZ") gStyle.SetLabelFont(42, "XYZ") gStyle.SetLabelOffset(0.007, "XYZ") gStyle.SetLabelSize(0.05, "XYZ") # For the axis: gStyle.SetAxisColor(1, "XYZ") gStyle.SetStripDecimals(True) gStyle.SetTickLength(0.03, "XYZ") gStyle.SetNdivisions(510, "XYZ") gStyle.SetPadTickX( 1) # To get tick marks on the opposite side of the frame gStyle.SetPadTickY(1) # Change for log plots: gStyle.SetOptLogx(0) gStyle.SetOptLogy(0) gStyle.SetOptLogz(0) # Postscript options: gStyle.SetPaperSize(20., 20.)
def cebefo_style(): #TStyle *gStyle = new TStyle("gStyle","gStyle"); gStyle.SetPadTickX(1) gStyle.SetPadTickY(1) gStyle.SetLineWidth(2) gStyle.SetFuncWidth(2) gStyle.SetHistLineWidth(3) gStyle.SetMarkerStyle(1) gStyle.SetTextSize(0.065) gStyle.SetOptFit(1111) # axis gStyle.SetTitleSize(.05, "X") #.055 gStyle.SetTitleOffset(1.1, "X") #1.2,0.9 #gStyle.SetLabelOffset(0.003,"X"); gStyle.SetLabelSize(.05, "X") #gStyle.SetLabelFont(42,"X"); gStyle.SetTitleSize(.05, "Y") #.055 gStyle.SetTitleOffset(1.5, "Y") #gStyle.SetLabelOffset(0.008,"Y"); gStyle.SetLabelSize(.05, "Y") #gStyle.SetLabelFont(42,"Y"); gStyle.SetTitleSize(.05, "Z") gStyle.SetTitleOffset(1.8, "Z") #gStyle.SetLabelOffset(0.008,"Z"); gStyle.SetLabelSize(0.05, "Z") #gStyle.SetLabelFont(42,"Z"); rt.TGaxis.SetMaxDigits(4) # Legend # gStyle.SetLegendTextSize(0.04); #gStyle.SetStatFontSize(0.2); #histograms properties gStyle.SetOptStat(112210) #gStyle.SetStripDecimals(False) #gStyle.SetLineStyleString(11,"20 10") # canvas #gStyle.SetCanvasColor(0); #gStyle.SetCanvasBorderSize(10); #gStyle.SetCanvasBorderMode(0); #gStyle.SetCanvasDefW(600); #gStyle.SetCanvasDefH(600); # pads # gStyle.SetPadColor(0); # gStyle.SetPadBorderSize(10); # gStyle.SetPadBorderMode(0); gStyle.SetPadLeftMargin(.14) gStyle.SetPadRightMargin(.02) gStyle.SetPadBottomMargin(.12) gStyle.SetPadTopMargin(.05) gStyle.SetPadGridX(1) gStyle.SetPadGridY(1)