Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
graphreverse.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_graphs
3/// \notebook
4/// This example test all the various case of reverse graphs
5/// combined with logarithmic scale.
6///
7/// \macro_image
8/// \macro_code
9///
10/// \author Olivier Couet
11
12void graphreverse()
13{
14 auto c = new TCanvas("c", "Reversed graphs", 0, 0, 900, 900);
15 c->Divide(3, 3);
16
17 // TGraphErrors
18 auto graphe = new TGraphErrors();
19 graphe->GetXaxis()->SetNdivisions(514);
20 graphe->GetYaxis()->SetNdivisions(514);
21 graphe->SetMarkerStyle(kCircle);
22 graphe->SetPoint(0, 5, 5);
23 graphe->SetPointError(0, 1, 3);
24 graphe->SetPoint(1, 9, 9);
25 graphe->SetPointError(1, 1, 3);
26
27 c->cd(1);
28 gPad->SetGrid();
29 graphe->Draw("a pl ");
30
31 c->cd(2);
32 gPad->SetGrid();
33 graphe->Draw("a pl rx ry ");
34
35 c->cd(3);
36 gPad->SetGrid();
37 gPad->SetLogx();
38 gPad->SetLogy();
39 graphe->GetXaxis()->SetMoreLogLabels();
40 graphe->GetYaxis()->SetMoreLogLabels();
41 graphe->Draw("a pl rx ry");
42
43 // TGraphAsymmErrors
44 auto graphae = new TGraphAsymmErrors();
45 graphae->GetXaxis()->SetNdivisions(514);
46 graphae->GetYaxis()->SetNdivisions(514);
47 graphae->SetMarkerStyle(kCircle);
48 graphae->SetPoint(0, 5, 5);
49 graphae->SetPointError(0, 1, 3, 3, 1);
50 graphae->SetPoint(1, 9, 9);
51 graphae->SetPointError(1, 1, 3, 1, 3);
52
53 c->cd(4);
54 gPad->SetGrid();
55 graphae->Draw("a pl ");
56
57 c->cd(5);
58 gPad->SetGrid();
59 graphae->Draw("a pl rx ry ");
60
61 c->cd(6);
62 gPad->SetGrid();
63 gPad->SetLogx();
64 gPad->SetLogy();
65 graphae->GetXaxis()->SetMoreLogLabels();
66 graphae->GetYaxis()->SetMoreLogLabels();
67 graphae->Draw("a pl rx ry");
68
69 // TGraphBentErrors
70 auto graphbe = new TGraphBentErrors();
71 graphbe->GetXaxis()->SetNdivisions(514);
72 graphbe->GetYaxis()->SetNdivisions(514);
73 graphbe->SetMarkerStyle(kCircle);
74 graphbe->SetPoint(0, 5, 5);
75 graphbe->SetPointError(0, 1, 3, 3, 1, .5, .2, .5, .2);
76 graphbe->SetPoint(1, 9, 9);
77 graphbe->SetPointError(1, 1, 3, 1, 3, -.5, -.2, -.5, -.2);
78
79 c->cd(7);
80 gPad->SetGrid();
81 graphbe->Draw("a pl ");
82
83 c->cd(8);
84 gPad->SetGrid();
85 graphbe->Draw("a pl rx ry ");
86
87 c->cd(9);
88 gPad->SetGrid();
89 gPad->SetLogx();
90 gPad->SetLogy();
91 graphbe->GetXaxis()->SetMoreLogLabels();
92 graphbe->GetYaxis()->SetMoreLogLabels();
93 graphbe->Draw("a pl rx ry");
94}
#define c(i)
Definition RSha256.hxx:101
@ kCircle
Definition TAttMarker.h:53
#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.