Logo ROOT  
Reference Guide
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Loading...
Searching...
No Matches
gr105_multigraphpalettecolor.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_graphs
3/// \notebook
4/// \preview Palette coloring for multi-graphs is activated thanks to the options PFC
5/// (Palette Fill Color), PLC (Palette Line Color) and AMC (Palette Marker Color).
6/// When one of these options is given to TMultiGraph::Draw the TGraphs in the
7/// TMultiGraph get their color from the current color palette defined by
8/// gStyle->SetPalette(...). The color is determined according to the number of
9/// TGraphs.
10///
11/// In this example four graphs are displayed with palette coloring for lines and
12/// and markers. The color of each graph is picked inside the default palette kBird.
13///
14/// \macro_image
15/// \macro_code
16/// \author Olivier Couet
17
19{
20 auto mg = new TMultiGraph();
21
22 auto gr1 = new TGraph(); gr1->SetMarkerStyle(20);
23 auto gr2 = new TGraph(); gr2->SetMarkerStyle(21);
24 auto gr3 = new TGraph(); gr3->SetMarkerStyle(23);
25 auto gr4 = new TGraph(); gr4->SetMarkerStyle(24);
26
27 Double_t dx = 6.28/100;
28 Double_t x = -3.14;
29
30 for (int i=0; i<=100; i++) {
31 x = x+dx;
32 gr1->SetPoint(i,x,2.*TMath::Sin(x));
33 gr2->SetPoint(i,x,TMath::Cos(x));
34 gr3->SetPoint(i,x,TMath::Cos(x*x));
35 gr4->SetPoint(i,x,TMath::Cos(x*x*x));
36 }
37
38 mg->Add(gr4,"PL");
39 mg->Add(gr3,"PL");
40 mg->Add(gr2,"*L");
41 mg->Add(gr1,"PL");
42
43 mg->Draw("A pmc plc");
44}
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.
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
Double_t x[n]
Definition legend1.C:17
Double_t Cos(Double_t)
Returns the cosine of an angle of x radians.
Definition TMath.h:598
Double_t Sin(Double_t)
Returns the sine of an angle of x radians.
Definition TMath.h:592