Logo ROOT   6.07/09
Reference Guide
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 
11 TCanvas *exclusiongraph() {
12  TCanvas *c1 = new TCanvas("c1","Exclusion graphs examples",200,10,600,400);
13  c1->SetGrid();
14 
15  TMultiGraph *mg = new TMultiGraph();
16  mg->SetTitle("Exclusion graphs");
17 
18  const Int_t n = 35;
19  Double_t xvalues1[n], xvalues2[n], xvalues3[n], yvalues1[n], yvalues2[n], yvalues3[n];
20  for (Int_t i=0;i<n;i++) {
21  xvalues1[i] = i*0.1;
22  xvalues2[i] = xvalues1[i];
23  xvalues3[i] = xvalues1[i]+.5;
24  yvalues1[i] = 10*sin(xvalues1[i]);
25  yvalues2[i] = 10*cos(xvalues1[i]);
26  yvalues3[i] = 10*sin(xvalues1[i])-2;
27  }
28 
29  TGraph *gr1 = new TGraph(n,xvalues1,yvalues1);
30  gr1->SetLineColor(2);
31  gr1->SetLineWidth(1504);
32  gr1->SetFillStyle(3005);
33 
34  TGraph *gr2 = new TGraph(n,xvalues2,yvalues2);
35  gr2->SetLineColor(4);
36  gr2->SetLineWidth(-2002);
37  gr2->SetFillStyle(3004);
38  gr2->SetFillColor(9);
39 
40  TGraph *gr3 = new TGraph(n,xvalues3,yvalues3);
41  gr3->SetLineColor(5);
42  gr3->SetLineWidth(-802);
43  gr3->SetFillStyle(3002);
44  gr3->SetFillColor(2);
45 
46  mg->Add(gr1);
47  mg->Add(gr2);
48  mg->Add(gr3);
49  mg->Draw("AC");
50 
51  return c1;
52 }
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
Definition: TAttLine.h:49
return c1
Definition: legend1.C:41
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)
Set the fill area style.
Definition: TAttFill.h:44
double cos(double)
virtual void SetGrid(Int_t valuex=1, Int_t valuey=1)
Definition: TPad.h:318
virtual void Draw(Option_t *chopt="")
Draw this multigraph with its current attributes.
double sin(double)
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition: TAttLine.h:46
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition: TAttFill.h:42
The Canvas class.
Definition: TCanvas.h:41
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="")
Set the title of the TNamed.
Definition: TNamed.cxx:155
const Int_t n
Definition: legend1.C:16