Logo ROOT  
Reference Guide
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Loading...
Searching...
No Matches
gr106_exclusiongraph.C File Reference

Detailed Description

View in nbviewer Open in SWAN
Draw three graphs with an exclusion zone.

The shaded areas are obtained with a fill for the graph and controlled with SetLineWidth. SetLineWidth for exclusion graphs is explained in the TGraphPainter documentation

As the graphs will be superposed on drawing, we add them to a TMultiGraph and then draw this one.

TCanvas *c1 = new TCanvas("c1","Exclusion graph examples",200,10,600,400);
c1->SetGrid();
TMultiGraph *mg = new TMultiGraph();
mg->SetTitle("Exclusion graphs");
const Int_t n = 35;
for (Int_t i=0;i<n;i++) {
xvalues1[i] = i*0.1;
xvalues2[i] = xvalues1[i];
xvalues3[i] = xvalues1[i]+.5;
yvalues1[i] = 10*sin(xvalues1[i]);
yvalues2[i] = 10*cos(xvalues1[i]);
yvalues3[i] = 10*sin(xvalues1[i])-2;
}
// See explanation for SetLineWidth above
gr1->SetLineColor(2);
gr1->SetLineWidth(1504);
gr1->SetFillStyle(3005);
gr2->SetLineColor(4);
gr2->SetLineWidth(-2002);
gr2->SetFillStyle(3004);
gr2->SetFillColor(9);
gr3->SetLineColor(5);
gr3->SetLineWidth(-802);
gr3->SetFillStyle(3002);
gr3->SetFillColor(2);
mg->Add(gr1);
mg->Add(gr2);
mg->Add(gr3);
mg->Draw("AC");
return c1;
}
int Int_t
Definition RtypesCore.h:45
double Double_t
Definition RtypesCore.h:59
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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
return c1
Definition legend1.C:41
const Int_t n
Definition legend1.C:16
Author
Olivier Couet

Definition in file gr106_exclusiongraph.C.