Logo ROOT  
Reference Guide
gmultierrors.C File Reference

Detailed Description

View in nbviewer Open in SWAN Draw a graph with multiple y errors

void gmultierrors() {
TCanvas *c1 = new TCanvas("c1", "A Simple Graph with multiple y-errors", 200, 10, 700, 500);
c1->SetGrid();
c1->GetFrame()->SetBorderSize(12);
const Int_t np = 5;
Double_t x[np] = {0, 1, 2, 3, 4};
Double_t y[np] = {0, 2, 4, 1, 3};
Double_t exl[np] = {0.3, 0.3, 0.3, 0.3, 0.3};
Double_t exh[np] = {0.3, 0.3, 0.3, 0.3, 0.3};
Double_t eylstat[np] = {1, 0.5, 1, 0.5, 1};
Double_t eyhstat[np] = {0.5, 1, 0.5, 1, 0.5};
Double_t eylsys[np] = {0.5, 0.4, 0.8, 0.3, 1.2};
Double_t eyhsys[np] = {0.6, 0.7, 0.6, 0.4, 0.8};
TGraphMultiErrors* gme = new TGraphMultiErrors("gme", "TGraphMultiErrors Example", np, x, y, exl, exh, eylstat, eyhstat);
gme->AddYError(np, eylsys, eyhsys);
gme->SetMarkerStyle(20);
gme->GetAttLine(0)->SetLineColor(kRed);
gme->GetAttLine(1)->SetLineColor(kBlue);
gme->GetAttFill(1)->SetFillStyle(0);
// Graph and x erros drawn with "APS"
// Stat Errors drawn with "Z"
// Sys Errors drawn with "5 s=0.5"
gme->Draw("APS ; Z ; 5 s=0.5");
c1->Update();
}
Author
Simon Spies

Definition in file gmultierrors.C.

TGraph::Draw
virtual void Draw(Option_t *chopt="")
Draw this graph with its current attributes.
Definition: TGraph.cxx:760
TGraphMultiErrors::AddYError
virtual void AddYError(Int_t np, const Double_t *eyL=nullptr, const Double_t *eyH=nullptr)
Add a new y error to the graph and fill it with the values from eyL and eyH.
Definition: TGraphMultiErrors.cxx:885
TGraphMultiErrors::GetAttFill
virtual TAttFill * GetAttFill(Int_t e)
Get AttFill pointer for specified error dimension.
Definition: TGraphMultiErrors.cxx:1587
TGraphMultiErrors
Definition: TGraphMultiErrors.h:29
Int_t
int Int_t
Definition: RtypesCore.h:45
x
Double_t x[n]
Definition: legend1.C:17
y
Double_t y[n]
Definition: legend1.C:17
TGraphMultiErrors::GetAttLine
virtual TAttLine * GetAttLine(Int_t e)
Get AttLine pointer for specified error dimension.
Definition: TGraphMultiErrors.cxx:1598
kRed
@ kRed
Definition: Rtypes.h:66
Double_t
double Double_t
Definition: RtypesCore.h:59
TCanvas
Definition: TCanvas.h:23
kBlue
@ kBlue
Definition: Rtypes.h:66
c1
return c1
Definition: legend1.C:41
TGraphMultiErrors::SetLineColor
virtual void SetLineColor(Int_t e, Color_t lcolor)
Set Line Color of error e (-1 = Global and x errors)
Definition: TGraphMultiErrors.cxx:2038