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();
24 gr1->SetMarkerStyle(20);
25 auto gr2 = new TGraph();
26 gr2->SetMarkerStyle(21);
27 auto gr3 = new TGraph();
28 gr3->SetMarkerStyle(23);
29 auto gr4 = new TGraph();
30 gr4->SetMarkerStyle(24);
31
32 Double_t dx = 6.28 / 100;
33 Double_t x = -3.14;
34
35 for (int i = 0; i <= 100; i++) {
36 x = x + dx;
37 gr1->SetPoint(i, x, 2. * TMath::Sin(x));
38 gr2->SetPoint(i, x, TMath::Cos(x));
39 gr3->SetPoint(i, x, TMath::Cos(x * x));
40 gr4->SetPoint(i, x, TMath::Cos(x * x * x));
41 }
42
43 mg->Add(gr4, "PL");
44 mg->Add(gr3, "PL");
45 mg->Add(gr2, "*L");
46 mg->Add(gr1, "PL");
47
48 mg->Draw("A pmc plc");
49}
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:598
Double_t Sin(Double_t)
Returns the sine of an angle of x radians.
Definition TMath.h:592