// include file for executables // makes canvases and histograms // the same as with macros // copied from ~/.rootlogon.C // 11/19/08 K Moriya #ifndef ROOTSTYLES_H #define ROOTSTYLES_H // -*- C++ -*- #include "TROOT.h" #include "TStyle.h" #include "TMath.h" #include "Math/IFunction.h" #include "TObject.h" #include "TColor.h" #include "TF1.h" void setMyStyle(){ gROOT->ForceStyle(); /* // 2011/08/17 // This is taken from a paper from KTeV, arXiv:1105.4800 // "Search for the Rare Decays KL->pi0pi0mu+mu- and KL->pi0pi0X0->pi0pi0mu+mu-" // The plot is saved as ~/rootstuff/KTeV-coolPlot.pdf const Int_t NRGBs = 5; const Int_t NCont = 255; Double_t stops[NRGBs] = { 0.00, 0.10, 0.61, 0.90, 1.00 }; Double_t red[NRGBs] = { 1.00, 0.00, 0.00, 0.70, 1.00 }; Double_t green[NRGBs] = { 1.00, 0.90, 0.05, 0.00, 0.00 }; Double_t blue[NRGBs] = { 1.00, 0.20, 1.00, 0.70, 1.00 }; TColor::InitializeColors(); TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont); gStyle->SetNumberContours(NCont); */ // to get beautiful 2D plots const Int_t NRGBs = 5; const Int_t NCont = 255; Double_t stops[NRGBs] = { 0.00, 0.34, 0.61, 0.84, 1.00 }; Double_t red[NRGBs] = { 0.00, 0.00, 0.87, 1.00, 0.51 }; Double_t green[NRGBs] = { 0.00, 0.81, 1.00, 0.20, 0.00 }; Double_t blue[NRGBs] = { 0.51, 1.00, 0.12, 0.00, 0.00 }; TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont); gStyle->SetNumberContours(NCont); // for colorful plots // for different variations of colors of 2D plots, // see functions in myrootlogon.C // gStyle->SetPalette(1,0); /* // for red for positive, blue for negative // remember to set min = - max const Int_t NRGBs = 5; const Int_t NCont = 255; Double_t stops[NRGBs] = { 0.00, 0.34, 0.61, 0.84, 1.00 }; Double_t red[NRGBs] = { 0.00, 0.00, 0.87, 1.00, 0.51 }; Double_t green[NRGBs] = { 0.00, 0.81, 1.00, 0.20, 0.00 }; Double_t blue[NRGBs] = { 0.51, 1.00, 0.12, 0.00, 0.00 }; TColor::InitializeColors(); TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont); gStyle->SetNumberContours(NCont); */ /* // for regular colors for positive, gray to black for negative // (taken from Ryan Dickson, 05/28/2010) // remember to set min = - max const Int_t NRGBs = 9; const Int_t NCont = 255; Double_t red[NRGBs] = {0,0.5 ,1 ,0.6 ,0,0 ,0 ,1 ,1} Double_t green[NRGBs] = {0,0.5 ,1 ,0 ,0,1 ,1 ,1 ,0} Double_t blue[NRGBs] = {0,0.5 ,1 ,0.6 ,1,1 ,0 ,0 ,0} Double_t stops[NRGBs] = {0,0.25,0.5,0.55,0.6,0.7,0.8,0.9 ,1.0} TColor::InitializeColors(); TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont); gStyle->SetNumberContours(NCont); */ // print date on canvases _______________________________________________________________ // optdate = 10*format + mode, // where // format = 0: "Wed Sep 25 17:10:35 2002", 1: "2002-09-25", 2: "2002-09-25 17:10:35" // mode = 1: bottom left, 2: bottom right, 3: top right /* gStyle->SetOptDate(12); // 2009-09-25 on bottom right corner gStyle->SetDateX(.98); // NDC x coordinate gStyle->SetDateY(.01); // NDC y coordinate gStyle->GetAttDate()->SetTextFont(132); gStyle->GetAttDate()->SetTextSize(0.050); gStyle->GetAttDate()->SetTextAngle(0); gStyle->GetAttDate()->SetTextAlign(31); gStyle->GetAttDate()->SetTextColor(kGray+3); */ // ______________________________________________________________________________________ // tick marks ___________________________________________________________________________ // set ticks on both sides of plot gStyle->SetPadTickX(1); gStyle->SetPadTickY(1); // tick length gStyle->SetTickLength(0.04,"XYZ"); // ______________________________________________________________________________________ // set divisions ________________________________________________________________________ // 5 = minor divisions, 10 = major divisions gStyle->SetNdivisions(510,"X"); gStyle->SetNdivisions(510,"Y"); // ______________________________________________________________________________________ // for stat box _________________________________________________________________________ gStyle->SetOptStat(0); gStyle->SetOptStat("nieoumr"); // parameter mode can be any combination of kKsSiourRmMen // n : name of histogram is printed // i : integral of bins printed // e : number of entries printed // o : number of overflows printed // u : number of underflows printed // m : mean value printed // M : mean value mean error values printed // r : rms printed // R : rms and rms error printed // k : kurtosis printed // K : kurtosis and kurtosis error printed // s : skewness printed // S : skewness and skewness error printed gStyle->SetStatBorderSize(0); // border size gStyle->SetStatColor(0); // background color gStyle->SetStatStyle(0); // style (0 is transparent, 1001 is not) gStyle->SetStatX(0.920); // top right corner in NDC (0.970 to align with histo frame) gStyle->SetStatY(0.930); // top right corner in NDC (0.970 to align with histo frame) gStyle->SetStatFont(132); gStyle->SetStatFontSize(0.040); // in pixels? strange format gStyle->SetStatFormat("6.4g"); gStyle->SetStatTextColor(16); gStyle->SetStatH(0.100); gStyle->SetStatW(0.200); // ______________________________________________________________________________________ // histograms ___________________________________________________________________________ gStyle->SetHistFillColor(17); // set default histo fill color gStyle->SetHistFillStyle(1001); // set default histo fill style gStyle->SetHistLineColor(15); gStyle->SetHistLineStyle(1); gStyle->SetHistLineWidth(1); gStyle->SetHistMinimumZero(); // set default histo minimum to 0 gStyle->SetHistTopMargin(0.030); gStyle->SetErrorX(.5); // percentage of bin to be filled with error bars // in x-dir. when draw option "E" is specified // (0.5 covers entire bin range) // for draw option "B" (bar histograms) gStyle->SetBarOffset(0.25); // bar graph offset from bin left edge (0.5 is center) gStyle->SetBarWidth(0.50); // bar graph width in terms of bin width (1 fills bin) // ______________________________________________________________________________________ // graphs _______________________________________________________________________________ gStyle->SetEndErrorSize(10); // size of lines on end of error bars in pixels // ______________________________________________________________________________________ // functions ____________________________________________________________________________ gStyle->SetFuncColor(kViolet-6); gStyle->SetFuncStyle(3); gStyle->SetFuncWidth(3); // ______________________________________________________________________________________ // set grid _____________________________________________________________________________ gStyle->SetGridStyle(3); gStyle->SetGridWidth(1); // ______________________________________________________________________________________ // legend _______________________________________________________________________________ gStyle->SetLegendBorderSize(0); // ______________________________________________________________________________________ // outer frame around histogram/graph ___________________________________________________ gStyle->SetFrameBorderMode(0); // to get rid of red lines around histogram/graph gStyle->SetFrameBorderSize(0); // thickness of frame around histogram/graph gStyle->SetFrameFillColor(0); // fill color of histogram/graph background gStyle->SetFrameFillStyle(0); // fill style of histogram/graph background gStyle->SetFrameLineColor(kBlack); // color of outer frame of histogram/graph background gStyle->SetFrameLineStyle(1); // linestyle of outer frame of histogram/graph background gStyle->SetFrameLineWidth(0); // linewidth of outer frame of histogram/graph background // Changes the margins around plots to better see the axis titles gStyle->SetPadTopMargin(0.03); gStyle->SetPadBottomMargin(0.13); gStyle->SetPadLeftMargin(0.14); gStyle->SetPadRightMargin(0.03); // ______________________________________________________________________________________ // TPad _________________________________________________________________________________ gStyle->SetPadBorderMode(0); gStyle->SetPadBorderSize(0); gStyle->SetPadColor(0); // inherited from TAttFill gStyle->SetFillStyle(0); // gStyle->SetFillColor(0); // no need to universally set grids // gStyle->SetPadGridX(1); // gStyle->SetPadGridY(1); // these are set above in the "ticks" section // gStyle->SetPadTickX(1); // gStyle->SetPadTickY(1); // ______________________________________________________________________________________ // canvas _______________________________________________________________________________ gStyle->SetCanvasBorderMode(0); // in general, bordermode = -1:down 0:none 1:up gStyle->SetCanvasBorderSize(0); gStyle->SetCanvasColor(0); gStyle->SetCanvasDefX(0); gStyle->SetCanvasDefY(0); gStyle->SetCanvasDefW(1200); gStyle->SetCanvasDefH(900); // set to 900 for unix // ______________________________________________________________________________________ // main title ___________________________________________________________________________ // always show title for histogram/graph gStyle->SetOptTitle(1); // change plot title position // align = 10*HorizontalAlign + VerticalAlign // 1=left adjusted, 2=centered, 3=right adjusted // 1=bottom adjusted, 2=centered, 3=top adjusted gStyle->SetTitleAlign(13); gStyle->SetTitleBorderSize(0); // for histogram/graph title position gStyle->SetTitleX(0.150); gStyle->SetTitleY(0.920); gStyle->SetTitleW(0.400); gStyle->SetTitleH(0.080); gStyle->SetTitleFont(22,"title"); // font for title (same function used for axis titles) gStyle->SetTitleFillColor(0); // fill color of title bar gStyle->SetTitleFontSize(2); // font size in pixels for fonts with precision type 3 gStyle->SetTitleStyle(0); gStyle->SetTitleTextColor(kBlack); // ______________________________________________________________________________________ // axis title ___________________________________________________________________________ gStyle->SetTitleColor(kBlack,"XYZ"); // color of axis titles // set axis titles bigger gStyle->SetTitleFont(132,"XYZ"); // font for title (same function used for titles) gStyle->SetTitleSize(0.040,"XYZ"); gStyle->SetTitleOffset(0.750,"X"); gStyle->SetTitleOffset(0.800,"Y"); // ______________________________________________________________________________________ // label numbers on axis ________________________________________________________________ gStyle->SetLabelFont(132,"xyz"); // font of numbers on axis gStyle->SetLabelOffset(0.004,"XYZ"); // offset of numbers on axis gStyle->SetLabelSize(0.035,"XYZ"); // size of label numbers on axis gStyle->SetLabelColor(kBlack,"XYZ"); // set color of label numbers on axes gStyle->SetAxisColor(kBlack,"XYZ"); // set axis color // ______________________________________________________________________________________ // inherited from TAttText ______________________________________________________________ gStyle->SetTextFont(132); // font for legend, etc. gStyle->SetTextColor(kBlack); // font color // ______________________________________________________________________________________ } #endif /* ROOTSTYLES_H */