ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
markerwarning.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_graphics
3 /// This script illustrates the danger of using asymmetric symbols.
4 ///
5 /// \macro_image
6 ///
7 /// Non-symmetric symbols should be used carefully in plotting.
8 /// These two graphs show how misleading a careless use of symbols can be.
9 /// The two plots represent the same data sets but because of a bad symbol
10 /// choice, the two plots on the top appear further apart than for the bottom
11 /// example.
12 /// \author Olivier Couet
13 
14 void markerwarning()
15 {
16  const int Nph = 14;
17  double np_ph[Nph] = {353.4,300.2,254.3,215.2,181.0,151.3,125.2,102.7,
18  83.3, 66.7, 52.5, 40.2, 30.2, 22.0};
19  double nc_ph[Nph] = {3.890,3.734,3.592,3.453,3.342,3.247,3.151,3.047,
20  2.965,2.858,2.701,2.599,2.486,2.328};
21  double npe_ph[Nph] = {10.068,9.004,8.086,7.304,6.620,6.026,5.504,5.054,
22  4.666,4.334,4.050,3.804,3.604,3.440};
23  double nce_ph[Nph] = {0.235,0.217,0.210,0.206,0.213,0.223,0.239,0.260,
24  0.283,0.318,0.356,0.405,0.465,0.545};
25 
26  const int Nbr = 6;
27  double np_br[Nbr] = {357.0,306.0,239.0,168.0,114.0, 73.0};
28  double nc_br[Nbr] = {3.501,3.275,3.155,3.060,3.053,3.014};
29  double npe_br[Nbr] = {8.000,11.000,10.000,9.000,9.000,8.000};
30  double nce_br[Nbr] = {0.318,0.311,0.306,0.319,0.370,0.429};
31 
32  TGraphErrors *phUP = new TGraphErrors(Nph,np_ph,nc_ph,npe_ph,nce_ph);
33  TGraphErrors *phDN = new TGraphErrors(Nph,np_ph,nc_ph,npe_ph,nce_ph);
34  TGraphErrors *brUP = new TGraphErrors(Nbr,np_br,nc_br,npe_br,nce_br);
35  TGraphErrors *brDN = new TGraphErrors(Nbr,np_br,nc_br,npe_br,nce_br);
36 
37  float Top_margin = 0.;
38  float Left_margin = 0.025;
39  float Right_margin = 0.005;
40  float maxPlotPart = 395;
41  float Marker_Size = 1.3;
42  int Marker_Style = 8;
43 
44  float Et_200_Min = 0.71;
45  float Et_200_Max = 3.80;
46  float Et_130_Min = 1.21;
47  float Et_130_Max = 3.29;
48 
49  float Nc_200_Min = 1.31;
50  float Nc_200_Max = 4.30;
51  float Nc_130_Min = 1.51;
52  float Nc_130_Max = 3.89;
53 
54  TCanvas *canvasNc = new TCanvas("canvasNc", "Multiplicity",630,10,600,500);
55 
56  gStyle->SetOptStat(0);
57  canvasNc->SetFillColor(10);
58  canvasNc->SetBorderSize(0);
59 
60  // Primitives in Nc200 pad
61  TPad *padNcUP = new TPad("padNcUP","200 GeV",0.07,0.60,1.,1.00);
62  padNcUP->Draw();
63  padNcUP->cd();
64  padNcUP->SetFillColor(10);
65  padNcUP->SetFrameFillColor(10);
66  padNcUP->SetBorderSize(0);
67  padNcUP->SetLeftMargin(Left_margin);
68  padNcUP->SetRightMargin(Right_margin);
69  padNcUP->SetTopMargin(Top_margin+0.005);
70  padNcUP->SetBottomMargin(0.00);
71 
72  TH1F* frameNcUP = new TH1F("frameNcUP","",100,0,maxPlotPart);
73  frameNcUP->GetYaxis()->SetLabelOffset(0.005);
74  frameNcUP->GetYaxis()->SetLabelSize(0.10);
75  frameNcUP->SetMinimum(Nc_200_Min);
76  frameNcUP->SetMaximum(Nc_200_Max);
77  frameNcUP->SetNdivisions(505,"Y");
78  frameNcUP->SetNdivisions(505,"X");
79  frameNcUP->Draw();
80 
81  brUP->SetMarkerStyle(22);
82  brUP->SetMarkerSize (2.0);
83  brUP->Draw("P");
84 
85  phDN->SetMarkerStyle(23);
86  phDN->SetMarkerSize (2);
87  phDN->Draw("P");
88 
89  canvasNc->cd();
90 
91  // Primitives in Nc130 pad
92  TPad *padNcDN = new TPad("padNcDN","130 GeV",0.07,0.02,1.,0.60);
93  padNcDN->Draw();
94  padNcDN->cd();
95  padNcDN->SetFillColor(10);
96  padNcDN->SetFrameFillColor(10);
97  padNcDN->SetBorderSize(0);
98  padNcDN->SetLeftMargin(Left_margin);
99  padNcDN->SetRightMargin(Right_margin);
100  padNcDN->SetTopMargin(Top_margin+0.005);
101  padNcDN->SetBottomMargin(0.30);
102 
103  TH1F* frameNcDN = new TH1F("frameNcDN","",100,0,maxPlotPart);
104  frameNcDN->GetYaxis()->SetLabelOffset(0.005);
105  frameNcDN->GetYaxis()->SetLabelSize(0.07);
106  frameNcDN->GetXaxis()->SetLabelOffset(0.005);
107  frameNcDN->GetXaxis()->SetLabelSize(0.07);
108  frameNcDN->SetMinimum(Nc_200_Min);
109  frameNcDN->SetMaximum(Nc_200_Max);
110  frameNcDN->SetNdivisions(505,"Y");
111  frameNcDN->SetNdivisions(505,"X");
112  frameNcDN->Draw();
113 
114  brDN->SetMarkerStyle(23);
115  brDN->SetMarkerSize (2.0);
116  brDN->Draw("P");
117 
118  phUP->SetMarkerStyle(22);
119  phUP->SetMarkerSize (2);
120  phUP->Draw("P");
121 
122  TLatex t1;
123  t1.SetTextFont(12); t1.SetTextSize(0.0525);
124  t1.DrawLatex(-5,0.6,"Non-symmetric symbols should be used carefully in plotting. \
125  These two graphs show how misleading");
126  t1.DrawLatex(-5,0.4,"a careless use of symbols can be. The two plots represent \
127  the same data sets but because of a bad");
128  t1.DrawLatex(-5,0.2,"symbol choice, the two plots on the top appear further apart \
129  than for the bottom example.");
130 
131  canvasNc->cd();
132 }
virtual void SetMaximum(Double_t maximum=-1111)
Definition: TH1.h:394
R__EXTERN TStyle * gStyle
Definition: TStyle.h:423
virtual void SetNdivisions(Int_t n=510, Option_t *axis="X")
Set the number of divisions to draw an axis.
Definition: Haxis.cxx:169
TVirtualPad * cd(Int_t subpadnumber=0)
Set current canvas & pad.
Definition: TCanvas.cxx:659
virtual void SetMinimum(Double_t minimum=-1111)
Definition: TH1.h:395
1-D histogram with a float per channel (see TH1 documentation)}
Definition: TH1.h:570
TLatex * t1
Definition: textangle.C:20
virtual void SetLabelOffset(Float_t offset=0.005)
Set distance between the axis and the labels The distance is expressed in per cent of the pad width...
Definition: TAttAxis.cxx:176
virtual void Draw(Option_t *chopt="")
Draw this graph with its current attributes.
Definition: TGraph.cxx:740
virtual void SetTopMargin(Float_t topmargin)
Set Pad top margin in fraction of the pad height.
Definition: TAttPad.cxx:127
virtual void SetTextFont(Font_t tfont=62)
Definition: TAttText.h:59
TVirtualPad * cd(Int_t subpadnumber=0)
Set Current pad.
Definition: TPad.cxx:514
To draw Mathematical Formula.
Definition: TLatex.h:33
TLatex * DrawLatex(Double_t x, Double_t y, const char *text)
Make a copy of this object with the new parameters And copy object attributes.
Definition: TLatex.cxx:1901
virtual void Draw(Option_t *option="")
Draw Pad in Current pad (re-parent pad if necessary).
Definition: TPad.cxx:1192
virtual void SetBottomMargin(Float_t bottommargin)
Set Pad bottom margin in fraction of the pad height.
Definition: TAttPad.cxx:97
virtual void Draw(Option_t *option="")
Draw this histogram with options.
Definition: TH1.cxx:2878
virtual void SetFillColor(Color_t fcolor)
Definition: TAttFill.h:50
The most important graphics class in the ROOT system.
Definition: TPad.h:46
virtual void SetMarkerStyle(Style_t mstyle=1)
Definition: TAttMarker.h:53
TAxis * GetYaxis()
Definition: TH1.h:320
virtual void SetLabelSize(Float_t size=0.04)
Set size of axis labels The size is expressed in per cent of the pad width.
Definition: TAttAxis.cxx:187
virtual void SetMarkerSize(Size_t msize=1)
Definition: TAttMarker.h:54
The Canvas class.
Definition: TCanvas.h:48
virtual void SetRightMargin(Float_t rightmargin)
Set Pad right margin in fraction of the pad width.
Definition: TAttPad.cxx:117
A TGraphErrors is a TGraph with error bars.
Definition: TGraphErrors.h:28
void SetOptStat(Int_t stat=1)
The type of information printed in the histogram statistics box can be selected via the parameter mod...
Definition: TStyle.cxx:1252
void SetFrameFillColor(Color_t color=1)
Definition: TAttPad.h:83
virtual void SetBorderSize(Short_t bordersize)
Definition: TPad.h:317
virtual void SetTextSize(Float_t tsize=1)
Definition: TAttText.h:60
TAxis * GetXaxis()
Definition: TH1.h:319
virtual void SetLeftMargin(Float_t leftmargin)
Set Pad left margin in fraction of the pad width.
Definition: TAttPad.cxx:107