Style.cxx
Go to the documentation of this file.
1 //____________________________________________________________________________
2 /*
3  Copyright (c) 2003-2019, The GENIE Collaboration
4  For the full text of the license visit http://copyright.genie-mc.org
5  or see $GENIE/LICENSE
6 
7  Author: Costas Andreopoulos <costas.andreopoulos \at stfc.ac.uk>
8  University of Liverpool & STFC Rutherford Appleton Lab
9 
10  For documentation see the corresponding header file.
11 
12  Important revisions after version 2.0.0 :
13  @ Jul 29, 2010 - CA
14  Added in v2.7.1
15 
16 */
17 //____________________________________________________________________________
18 
19 #include <TROOT.h>
20 #include <TStyle.h>
21 #include <TColor.h>
22 #include <TGraph.h>
23 #include <TH1.h>
24 
25 #include "Framework/Utils/Style.h"
26 
27 //___________________________________________________________________________
28 void genie::utils::style::SetDefaultStyle(bool black_n_white)
29 {
30  gROOT->SetStyle("Plain");
31 
32  gStyle -> SetPadTickX (1);
33  gStyle -> SetPadTickY (1);
34 
35  //
36  // Turn off all borders
37  //
38  gStyle -> SetCanvasBorderMode (0);
39  gStyle -> SetFrameBorderMode (0);
40  gStyle -> SetPadBorderMode (0);
41  gStyle -> SetDrawBorder (0);
42  gStyle -> SetCanvasBorderSize (0);
43  gStyle -> SetFrameBorderSize (0);
44  gStyle -> SetPadBorderSize (0);
45  gStyle -> SetTitleBorderSize (0);
46 
47  //
48  // Set the size of the default canvas
49  //
50  gStyle -> SetCanvasDefH (600);
51  gStyle -> SetCanvasDefW (730);
52  gStyle -> SetCanvasDefX (10);
53  gStyle -> SetCanvasDefY (10);
54 
55  //
56  // Set marker style
57  //
58  gStyle -> SetMarkerStyle (20);
59  gStyle -> SetMarkerSize (1);
60 
61  //
62  // Set line widths
63  //
64  gStyle -> SetFrameLineWidth (1);
65  gStyle -> SetFuncWidth (2);
66  gStyle -> SetHistLineWidth (3);
67  gStyle -> SetFuncColor (2);
68  gStyle -> SetFuncWidth (3);
69 
70  //
71  // Set margins
72  //
73  gStyle -> SetPadTopMargin (0.10);
74  gStyle -> SetPadBottomMargin (0.20);
75  gStyle -> SetPadLeftMargin (0.15);
76  gStyle -> SetPadRightMargin (0.03);
77 
78  //
79  // Set tick marks and turn off grids
80  //
81  gStyle -> SetNdivisions (505,"xyz");
82 
83  //
84  // Adjust size and placement of axis labels
85  //
86  gStyle -> SetLabelSize (0.050, "xyz");
87  gStyle -> SetLabelOffset (0.005, "x" );
88  gStyle -> SetLabelOffset (0.005, "y" );
89  gStyle -> SetLabelOffset (0.005, "z" );
90  gStyle -> SetTitleSize (0.060, "xyz");
91  gStyle -> SetTitleOffset (1.200, "xz" );
92  gStyle -> SetTitleOffset (1.000, "y" );
93 
94  // Set Data/Stat/... and other options
95  //
96  gStyle -> SetOptDate (0);
97  gStyle -> SetOptFile (0);
98  gStyle -> SetOptStat (0);
99  gStyle -> SetStatFormat ("6.2f");
100  gStyle -> SetFitFormat ("8.4f");
101  gStyle -> SetOptFit (1);
102  gStyle -> SetStatH (0.20);
103  gStyle -> SetStatStyle (0);
104  gStyle -> SetStatW (0.30);
105  gStyle -> SetStatX (0.845);
106  gStyle -> SetStatY (0.845);
107  gStyle -> SetOptTitle (0);
108  gStyle -> SetTitleX (0.15);
109  gStyle -> SetTitleW (0.75);
110  gStyle -> SetTitleY (0.90);
111  gStyle -> SetPalette (1);
112  gStyle -> SetLegendBorderSize (0);
113 
114  //
115  // Set paper size for life in the US or EU
116  //
117  gStyle -> SetPaperSize (TStyle::kA4); //<-- tartes aux fraises
118 //gStyle -> SetPaperSize (TStyle::kUSLetter); //<-- donuts
119 
120  //
121  // In B&W (papers)
122  //
123  if(black_n_white){
124  const int ncol = 7;
125 
126  double red [ncol];
127  double green [ncol];
128  double blue [ncol];
129  double stops [ncol];
130 
131  double dcol = -1/double(ncol);
132  double gray = 1;
133  for (int j = 0; j < ncol; j++) {
134  // Define color with RGB equal to : gray, gray, gray
135  stops[j] = double(j)/double(ncol-1);
136  red [j] = gray;
137  blue [j] = gray;
138  green[j] = gray;
139 
140  gray += dcol;
141  }
142  UInt_t totcol=50;
143  TColor::CreateGradientColorTable(ncol,stops,red,green,blue,totcol);
144 
145  gStyle -> SetFuncWidth (1);
146  gStyle -> SetHistLineWidth (1);
147  gStyle -> SetFuncColor (1);
148  gStyle -> SetFuncWidth (1);
149  }//bw
150 
151  gROOT->ForceStyle();
152 }
153 //___________________________________________________________________________
155  TGraph* gr, int lcol, int lsty, int lwid, int mcol, int msty, double msiz)
156 {
157  if(!gr) return;
158 
159  if (lcol >= 0) gr -> SetLineColor (lcol);
160  if (lsty >= 0) gr -> SetLineStyle (lsty);
161  if (lwid >= 0) gr -> SetLineWidth (lwid);
162 
163  if (mcol >= 0) gr -> SetMarkerColor (mcol);
164  if (msty >= 0) gr -> SetMarkerStyle (msty);
165  if (msiz >= 0) gr -> SetMarkerSize (msiz);
166 }
167 //___________________________________________________________________________
169  TH1* hst, int lcol, int lsty, int lwid, int mcol, int msty, double msiz)
170 {
171  if(!hst) return;
172 
173  if (lcol >= 0) hst -> SetLineColor (lcol);
174  if (lsty >= 0) hst -> SetLineStyle (lsty);
175  if (lwid >= 0) hst -> SetLineWidth (lwid);
176 
177  if (mcol >= 0) hst -> SetMarkerColor (mcol);
178  if (msty >= 0) hst -> SetMarkerStyle (msty);
179  if (msiz >= 0) hst -> SetMarkerSize (msiz);
180 }
181 //___________________________________________________________________________
182 
hmean SetLineStyle(2)
gStyle SetOptFit(1)
fVtxDx SetMarkerStyle(20)
void SetDefaultStyle(bool black_n_white=false)
Definition: Style.cxx:28
hipStyle SetTitleBorderSize(0)
tuple blue
Definition: rootlogon.py:65
hmean SetLineWidth(2)
hmean SetLineColor(4)
h1 SetMarkerColor(4)
const double j
Definition: BetheBloch.cxx:29
hipStyle SetHistLineWidth(2)
hipStyle SetPadBottomMargin(0.10)
gStyle SetPalette(1)
void Format(TGraph *gr, int lcol, int lsty, int lwid, int mcol, int msty, double msiz)
Definition: Style.cxx:154
GRdata SetMarkerSize(1.0)
static constexpr Double_t gray
Definition: Munits.h:390
gStyle SetOptStat(111111)
hipStyle SetPadLeftMargin(0.20)