23 #include "ROOT/RLegend.hxx"
28 R__LOAD_LIBRARY(libROOTHistDraw)
30 using namespace ROOT::Experimental;
35 RAxisConfig xaxis(25, 0., 10.);
36 auto pHist = std::make_shared<RH1D>(xaxis);
37 auto pHist2 = std::make_shared<RH1D>(xaxis);
39 for (
int n=0;n<1000;n++) {
40 pHist->Fill(gRandom->Gaus(3,0.8));
41 pHist2->Fill(gRandom->Gaus(7,1.2));
45 auto canvas = RCanvas::Create(
"Canvas Title");
48 auto draw1 = canvas->Draw(pHist);
49 draw1->AttrLine().SetWidth(2).Color().SetAuto();
52 auto draw2 = canvas->Draw(pHist2);
53 draw2->AttrLine().SetWidth(4).Color().SetAuto();
55 canvas->AssignAutoColors();
57 auto legend = canvas->Draw<RLegend>(RPadPos(0.5_normal, 0.6_normal), RPadPos(0.9_normal,0.9_normal),
"Legend title");
58 legend->AttrBox().AttrFill().SetStyle(5).SetColor(RColor::kWhite);
59 legend->AttrBox().AttrBorder().SetWidth(2).SetColor(RColor::kRed);
60 legend->AddEntry(draw1,
"histo1").SetLine(
"line_");
61 legend->AddEntry(draw2,
"histo2").SetLine(
"line_");