Logo ROOT  
Reference Guide
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Loading...
Searching...
No Matches
gr112_reverse_graph_and_errors.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_graphs
3/// \notebook
4/// \preview This example tests all the various cases of reverse graphs obtained with Draw("a pl rx ry "), where rx and ry refer to the reversing of x and y axis.
5///
6/// \macro_image
7/// \macro_code
8///
9/// \author Olivier Couet
10
12 auto c = new TCanvas("c","Reversed graphs",0,0,900,900);
13 c->Divide(3,3);
14
15 //TGraphErrors (first row example)
16 auto graphe = new TGraphErrors();
17 graphe->GetXaxis()->SetNdivisions(514);
18 graphe->GetYaxis()->SetNdivisions(514);
19 graphe->SetMarkerStyle(kCircle);
20 graphe->SetPoint(0,5,5);
21 graphe->SetPointError(0,1,3);
22 graphe->SetPoint(1,9,9);
23 graphe->SetPointError(1,1,3);
24
25 c->cd(1);
26 gPad->SetGrid();
27 graphe->Draw("a pl "); //Plot with axis ("a") and line+points ("pl")
28
29 c->cd(2);
30 gPad->SetGrid();
31 graphe->Draw("a pl rx ry "); //Plot with axis ("a") and line+points ("pl") with reverse X and Y axes
32
33 c->cd(3);
34 gPad->SetGrid();
35 gPad->SetLogx();
36 gPad->SetLogy();
37 graphe->GetXaxis()->SetMoreLogLabels();
38 graphe->GetYaxis()->SetMoreLogLabels();
39 graphe->Draw("a pl rx ry"); //Plot with reverse axis and log scale
40
41 //TGraphAsymmErrors (second row example)
42 auto graphae = new TGraphAsymmErrors();
43 graphae->GetXaxis()->SetNdivisions(514);
44 graphae->GetYaxis()->SetNdivisions(514);
45 graphae->SetMarkerStyle(kCircle);
46 graphae->SetPoint(0,5,5);
47 graphae->SetPointError(0,1,3,3,1);
48 graphae->SetPoint(1,9,9);
49 graphae->SetPointError(1,1,3,1,3);
50
51 c->cd(4);
52 gPad->SetGrid();
53 graphae->Draw("a pl ");
54
55 c->cd(5);
56 gPad->SetGrid();
57 graphae->Draw("a pl rx ry ");
58
59 c->cd(6);
60 gPad->SetGrid();
61 gPad->SetLogx();
62 gPad->SetLogy();
63 graphae->GetXaxis()->SetMoreLogLabels();
64 graphae->GetYaxis()->SetMoreLogLabels();
65 graphae->Draw("a pl rx ry");
66
67 //TGraphBentErrors (third row example)
68 auto graphbe = new TGraphBentErrors();
69 graphbe->GetXaxis()->SetNdivisions(514);
70 graphbe->GetYaxis()->SetNdivisions(514);
71 graphbe->SetMarkerStyle(kCircle);
72 graphbe->SetPoint(0,5,5);
73 graphbe->SetPointError(0,1,3,3,1,.5,.2,.5,.2);
74 graphbe->SetPoint(1,9,9);
75 graphbe->SetPointError(1,1,3,1,3,-.5,-.2,-.5,-.2);
76
77 c->cd(7);
78 gPad->SetGrid();
79 graphbe->Draw("a pl ");
80
81 c->cd(8);
82 gPad->SetGrid();
83 graphbe->Draw("a pl rx ry ");
84
85 c->cd(9);
86 gPad->SetGrid();
87 gPad->SetLogx();
88 gPad->SetLogy();
89 graphbe->GetXaxis()->SetMoreLogLabels();
90 graphbe->GetYaxis()->SetMoreLogLabels();
91 graphbe->Draw("a pl rx ry");
92}
#define c(i)
Definition RSha256.hxx:101
@ kCircle
Definition TAttMarker.h:56
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
#define gPad
The Canvas class.
Definition TCanvas.h:23
TGraph with asymmetric error bars.
A TGraphBentErrors is a TGraph with bent, asymmetric error bars.
A TGraphErrors is a TGraph with error bars.