Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
gr102_reverse_graph.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_graphs
3/// \notebook
4/// \preview This example tests the reverse graphs obtained with Draw("a pl rx ry ") on a TGraph, where rx and ry refere to the reversing of x and y axis.
5///
6/// \macro_image
7/// \macro_code
8///
9/// \author Olivier Couet
10
11void gr102_reverse_graph() {
12 auto c = new TCanvas("c","Reversed graphs",0,0,900,400);
13 c->Divide(2,1); //Create a canvas with a 2x1 grid layout
14
15 auto gr = new TGraph();
16 gr->GetXaxis()->SetNdivisions(514);
17 gr->GetYaxis()->SetNdivisions(514);
18 gr->SetMarkerStyle(kCircle);
19 gr->SetMarkerColor(kBlue);
20 gr->SetLineColor(kRed);
21 gr->SetPoint(0,5,5);
22 gr->SetPoint(1,9,9);
23 gr->SetPoint(2,14,14);
24
25
26 c->cd(1);
27 gPad->SetGrid();
28 gr->Draw("a pl "); //Plot with axis ("a") and line+points ("pl")
29
30 c->cd(2);
31 gPad->SetGrid();
32 gr->Draw("a pl rx ry "); //Plot with axis ("a") and line+points ("pl") with reverse X and Y axes
33
34}
#define c(i)
Definition RSha256.hxx:101
@ kRed
Definition Rtypes.h:67
@ kBlue
Definition Rtypes.h:67
@ kCircle
Definition TAttMarker.h:58
#define gPad
The Canvas class.
Definition TCanvas.h:23
TGraphErrors * gr
Definition legend1.C:25