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