1 #ifndef __JROOT__JLEGEND__
2 #define __JROOT__JLEGEND__
16 namespace JPP {
using namespace JROOT; }
30 const std::string option =
"TR")
36 const Double_t X1 = 0.0 + gPad->GetLeftMargin();
37 const Double_t X2 = 1.0 - gPad->GetRightMargin();
38 const Double_t Y1 = 0.0 + gPad->GetBottomMargin();
39 const Double_t Y2 = 1.0 - gPad->GetTopMargin();
41 const Double_t
w = gPad->XtoPixel(gPad->GetX2());
42 const Double_t h = gPad->YtoPixel(gPad->GetY1());
43 const Double_t ch = gStyle->GetStatFontSize() * (
w < h ?
w : h);
45 const Double_t fx = 0.70 * ch/
w;
46 const Double_t fy = 1.10 * ch/h;
47 const Double_t eps = 0.005;
56 Double_t W = (wd + nc) * fx;
57 Double_t
H = (height) * fy;
61 if (fc * W > X2 - X1 - 2*eps) {
62 fc *= (X2 - X1 - 2*eps) / W;
65 if (fc *
H > Y2 - Y1 - 2*eps) {
66 fc *= (Y2 - Y1 - 2*eps) /
H;
74 Double_t x1 = X2 - W - eps;
75 Double_t y1 = Y2 -
H - eps;
76 Double_t x2 = X2 - eps;
77 Double_t y2 = Y2 - eps;
82 if (option.find(
'T') != string::npos && option.find(
'B') == string::npos) {
90 if (option.find(
'B') != string::npos && option.find(
'T') == string::npos) {
98 if (option.find(
'R') != string::npos && option.find(
'L') == string::npos) {
106 if (option.find(
'L') != string::npos && option.find(
'R') == string::npos) {
114 TLegend* lg =
new TLegend(x1, y1, x2, y2);
116 lg->SetTextAlign(halign*10 + valign);
119 lg->SetFillColor(kWhite);
120 lg->SetBorderSize(0);
121 lg->SetTextAlign(12);
122 lg->SetTextFont(gStyle->GetStatFont());
123 lg->SetTextSize(gStyle->GetStatFontSize());
125 lg->SetMargin((Double_t) nc / (Double_t) (wd + nc));
static const double H
Planck constant [eV s].
TLegend * getLegend(const Int_t width, const Int_t height, const std::string option="TR")
Get legend.