ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
exclusiongraph.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_graphs
3 /// Draw three graphs with an exclusion zone.
4 ///
5 /// \macro_image
6 /// \macro_code
7 ///
8 /// \author Olivier Couet
9 
10 TCanvas *exclusiongraph() {
11  TCanvas *c1 = new TCanvas("c1","Exclusion graphs examples",200,10,600,400);
12  c1->SetGrid();
13 
14  TMultiGraph *mg = new TMultiGraph();
15  mg->SetTitle("Exclusion graphs");
16 
17  const Int_t n = 35;
18  Double_t x1[n], x2[n], x3[n], y1[n], y2[n], y3[n];
19  for (Int_t i=0;i<n;i++) {
20  x1[i] = i*0.1;
21  x2[i] = x1[i];
22  x3[i] = x1[i]+.5;
23  y1[i] = 10*sin(x1[i]);
24  y2[i] = 10*cos(x1[i]);
25  y3[i] = 10*sin(x1[i])-2;
26  }
27 
28  TGraph *gr1 = new TGraph(n,x1,y1);
29  gr1->SetLineColor(2);
30  gr1->SetLineWidth(1504);
31  gr1->SetFillStyle(3005);
32 
33  TGraph *gr2 = new TGraph(n,x2,y2);
34  gr2->SetLineColor(4);
35  gr2->SetLineWidth(-2002);
36  gr2->SetFillStyle(3004);
37  gr2->SetFillColor(9);
38 
39  TGraph *gr3 = new TGraph(n,x3,y3);
40  gr3->SetLineColor(5);
41  gr3->SetLineWidth(-802);
42  gr3->SetFillStyle(3002);
43  gr3->SetFillColor(2);
44 
45  mg->Add(gr1);
46  mg->Add(gr2);
47  mg->Add(gr3);
48  mg->Draw("AC");
49 
50  return c1;
51 }
virtual void SetLineWidth(Width_t lwidth)
Definition: TAttLine.h:57
TCanvas * c1
Definition: legend1.C:2
A TMultiGraph is a collection of TGraph (or derived) objects.
Definition: TMultiGraph.h:37
int Int_t
Definition: RtypesCore.h:41
virtual void SetFillStyle(Style_t fstyle)
Definition: TAttFill.h:52
double cos(double)
virtual void SetGrid(Int_t valuex=1, Int_t valuey=1)
Definition: TPad.h:326
virtual void Draw(Option_t *chopt="")
Draw this multigraph with its current attributes.
double sin(double)
virtual void SetLineColor(Color_t lcolor)
Definition: TAttLine.h:54
virtual void SetFillColor(Color_t fcolor)
Definition: TAttFill.h:50
The Canvas class.
Definition: TCanvas.h:48
double Double_t
Definition: RtypesCore.h:55
A Graph is a graphics object made of two arrays X and Y with npoints each.
Definition: TGraph.h:53
virtual void Add(TGraph *graph, Option_t *chopt="")
Add a new graph to the list of graphs.
virtual void SetTitle(const char *title="")
Change (i.e. set) the title of the TNamed.
Definition: TNamed.cxx:152
const Int_t n
Definition: legend1.C:16