This macro generates two TH1D objects and build RLegend In addition use of auto colors are shown.
#include "ROOT/RLegend.hxx"
void draw_legend()
{
RAxisConfig xaxis(25, 0., 10.);
auto pHist = std::make_shared<RH1D>(xaxis);
auto pHist2 = std::make_shared<RH1D>(xaxis);
for (
int n=0;
n<1000;
n++) {
}
auto canvas = RCanvas::Create("Canvas Title");
auto draw1 = canvas->Draw(pHist);
draw1->AttrLine().SetWidth(2).Color().SetAuto();
auto draw2 = canvas->Draw(pHist2);
draw2->AttrLine().SetWidth(4).Color().SetAuto();
canvas->AssignAutoColors();
auto legend = canvas->Draw<RLegend>(RPadPos(0.5_normal, 0.6_normal), RPadPos(0.9_normal,0.9_normal), "Legend title");
legend->AttrBox().AttrBorder().SetWidth(2).SetColor(
RColor::kRed);
legend->AddEntry(draw1, "histo1").SetLine("line_");
legend->AddEntry(draw2, "histo2").SetLine("line_");
canvas->Show();
}
#define R__LOAD_LIBRARY(LIBRARY)
R__EXTERN TRandom * gRandom
virtual Double_t Gaus(Double_t mean=0, Double_t sigma=1)
Samples a random number from the standard Normal (Gaussian) Distribution with the given mean and sigm...
- Date
- 2019-10-09
- Warning
- This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
- Author
- Sergey Linev s.lin.nosp@m.ev@g.nosp@m.si.de
Definition in file draw_legend.cxx.