Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
exclusiongraph.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_graphs
3/// \notebook
4/// Draw three graphs with an exclusion zone.
5///
6/// \macro_image
7/// \macro_code
8///
9/// \author Olivier Couet
10
11TCanvas *exclusiongraph()
12{
13 TCanvas *c1 = new TCanvas("c1", "Exclusion graphs examples", 200, 10, 600, 400);
14 c1->SetGrid();
15
16 TMultiGraph *mg = new TMultiGraph();
17 mg->SetTitle("Exclusion graphs");
18
19 const Int_t n = 35;
20 Double_t xvalues1[n], xvalues2[n], xvalues3[n], yvalues1[n], yvalues2[n], yvalues3[n];
21 for (Int_t i = 0; i < n; i++) {
22 xvalues1[i] = i * 0.1;
23 xvalues2[i] = xvalues1[i];
24 xvalues3[i] = xvalues1[i] + .5;
25 yvalues1[i] = 10 * sin(xvalues1[i]);
26 yvalues2[i] = 10 * cos(xvalues1[i]);
27 yvalues3[i] = 10 * sin(xvalues1[i]) - 2;
28 }
29
30 TGraph *gr1 = new TGraph(n, xvalues1, yvalues1);
31 gr1->SetLineColor(2);
32 gr1->SetLineWidth(1504);
33 gr1->SetFillStyle(3005);
34
35 TGraph *gr2 = new TGraph(n, xvalues2, yvalues2);
36 gr2->SetLineColor(4);
37 gr2->SetLineWidth(-2002);
38 gr2->SetFillStyle(3004);
39 gr2->SetFillColor(9);
40
41 TGraph *gr3 = new TGraph(n, xvalues3, yvalues3);
42 gr3->SetLineColor(5);
43 gr3->SetLineWidth(-802);
44 gr3->SetFillStyle(3002);
45 gr3->SetFillColor(2);
46
47 mg->Add(gr1);
48 mg->Add(gr2);
49 mg->Add(gr3);
50 mg->Draw("AC");
51
52 return c1;
53}
int Int_t
Definition RtypesCore.h:45
double Double_t
Definition RtypesCore.h:59
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition TAttFill.h:37
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
Definition TAttFill.h:39
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
Definition TAttLine.h:43
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition TAttLine.h:40
The Canvas class.
Definition TCanvas.h:23
A TGraph is an object made of two arrays X and Y with npoints each.
Definition TGraph.h:41
A TMultiGraph is a collection of TGraph (or derived) objects.
Definition TMultiGraph.h:34
virtual void Add(TGraph *graph, Option_t *chopt="")
Add a new graph to the list of graphs.
void Draw(Option_t *chopt="") override
Draw this multigraph with its current attributes.
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition TNamed.cxx:164
RVec< PromoteType< T > > cos(const RVec< T > &v)
Definition RVec.hxx:1852
RVec< PromoteType< T > > sin(const RVec< T > &v)
Definition RVec.hxx:1851
return c1
Definition legend1.C:41
const Int_t n
Definition legend1.C:16