Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
multigraphpalettecolor.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_graphs
3/// \notebook
4/// 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 `TGraph`s 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/// `TGraph`s.
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///
17/// \author Olivier Couet
18
19void multigraphpalettecolor()
20{
21 auto mg = new TMultiGraph();
22
23 auto gr1 = new TGraph(); gr1->SetMarkerStyle(20);
24 auto gr2 = new TGraph(); gr2->SetMarkerStyle(21);
25 auto gr3 = new TGraph(); gr3->SetMarkerStyle(23);
26 auto gr4 = new TGraph(); gr4->SetMarkerStyle(24);
27
28 Double_t dx = 6.28/100;
29 Double_t x = -3.14;
30
31 for (int i=0; i<=100; i++) {
32 x = x+dx;
33 gr1->SetPoint(i,x,2.*TMath::Sin(x));
34 gr2->SetPoint(i,x,TMath::Cos(x));
35 gr3->SetPoint(i,x,TMath::Cos(x*x));
36 gr4->SetPoint(i,x,TMath::Cos(x*x*x));
37 }
38
39 mg->Add(gr4,"PL");
40 mg->Add(gr3,"PL");
41 mg->Add(gr2,"*L");
42 mg->Add(gr1,"PL");
43
44 mg->Draw("A pmc plc");
45}
double Double_t
Definition RtypesCore.h:59
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:594
Double_t Sin(Double_t)
Returns the sine of an angle of x radians.
Definition TMath.h:588