Logo ROOT  
Reference Guide
multigraphpalettecolor.C File Reference

Detailed Description

View in nbviewer Open in SWAN Palette coloring for multi-graphs is activated thanks to the options PFC (Palette Fill Color), PLC (Palette Line Color) and AMC (Palette Marker Color). When one of these options is given to TMultiGraph::Draw the TGraphs in the TMultiGraphget their color from the current color palette defined by gStyle->SetPalette(…). The color is determined according to the number of TGraphs.

In this example four graphs are displayed with palette coloring for lines and and markers. The color of each graph is picked inside the default palette kBird.

void multigraphpalettecolor()
{
auto mg = new TMultiGraph();
auto gr1 = new TGraph(); gr1->SetMarkerStyle(20);
auto gr2 = new TGraph(); gr2->SetMarkerStyle(21);
auto gr3 = new TGraph(); gr3->SetMarkerStyle(23);
auto gr4 = new TGraph(); gr4->SetMarkerStyle(24);
Double_t dx = 6.28/100;
Double_t x = -3.14;
for (int i=0; i<=100; i++) {
x = x+dx;
gr1->SetPoint(i,x,2.*TMath::Sin(x));
gr2->SetPoint(i,x,TMath::Cos(x));
gr3->SetPoint(i,x,TMath::Cos(x*x));
gr4->SetPoint(i,x,TMath::Cos(x*x*x));
}
mg->Add(gr4,"PL");
mg->Add(gr3,"PL");
mg->Add(gr2,"*L");
mg->Add(gr1,"PL");
mg->Draw("A pmc plc");
}
Author
Olivier Couet

Definition in file multigraphpalettecolor.C.

TGeant4Unit::mg
static constexpr double mg
Definition: TGeant4SystemOfUnits.h:210
TMath::Cos
Double_t Cos(Double_t)
Definition: TMath.h:643
x
Double_t x[n]
Definition: legend1.C:17
TMath::Sin
Double_t Sin(Double_t)
Definition: TMath.h:639
TGraph::SetPoint
virtual void SetPoint(Int_t i, Double_t x, Double_t y)
Set x and y values for point number i.
Definition: TGraph.cxx:2269
TMultiGraph
A TMultiGraph is a collection of TGraph (or derived) objects.
Definition: TMultiGraph.h:36
Double_t
double Double_t
Definition: RtypesCore.h:59
TGraph
Definition: TGraph.h:41