Create a ROOT TLegend Fill Box: A Guide

  • Thread starter ChrisVer
  • Start date
  • Tags
    Box Root
In summary, to create a ROOT TLegend fill box, you can use the TLegend::AddEntry() function and set the fill style to a non-zero value. You can customize the fill box in the TLegend using the TLegend::SetFillStyle() and TLegend::SetFillColor() functions. To add multiple entries with fill boxes, use TLegend::AddEntry() for each entry and set the fill style. To remove the fill box from a specific entry, use TLegend::SetFillStyle() and set the fill style to zero. To change the size of the fill box, use TLegend::SetFillStyle() and set a larger value for all entries or specify the entry number and desired fill style for a specific
  • #1
ChrisVer
Gold Member
3,378
464
Does someone know how I can make such a legend entry in ROOT?

entry.png


I have tried all the draw options ("L","F","E") but I am unable to get this result.
It really looks like a mixture of LF, but LF draws me a rectangular box enclosed in black line.

extra info: I am using two graphs, one is for the error band and the other is for the line inbetween.
 
Technology news on Phys.org
  • #2
The ROOT Forum is the place to get answers to ROOT questions like this one.
 

1. How do I create a ROOT TLegend fill box?

To create a ROOT TLegend fill box, you can use the TLegend::AddEntry() function. This function takes in the object you want to add to the legend, a label for the object, and an optional fill style parameter. By setting the fill style to a non-zero value, the legend will automatically create a fill box for that particular entry.

2. Can I customize the fill box in the TLegend?

Yes, you can customize the fill box in the TLegend by using the TLegend::SetFillStyle() function. This function takes in the entry number and the desired fill style. You can also use the TLegend::SetFillColor() function to change the color of the fill box.

3. How do I add multiple entries with fill boxes to a TLegend?

To add multiple entries with fill boxes to a TLegend, you can use the TLegend::AddEntry() function for each entry you want to add. Make sure to set the fill style for each entry, and they will automatically be added with fill boxes to the legend.

4. Can I remove the fill box from a specific entry in the TLegend?

Yes, you can remove the fill box from a specific entry in the TLegend by using the TLegend::SetFillStyle() function and setting the fill style to zero for that particular entry. This will remove the fill box while still keeping the entry in the legend.

5. Is it possible to change the size of the fill box in the TLegend?

Yes, you can change the size of the fill box in the TLegend by using the TLegend::SetFillStyle() function and setting the fill style to a larger value. This will increase the size of the fill box for all entries in the legend. Alternatively, you can use the TLegend::SetFillStyle() function to change the fill box size for a specific entry by specifying the entry number and the desired fill style.

Similar threads

  • Programming and Computer Science
Replies
1
Views
1K
  • Programming and Computer Science
Replies
1
Views
11K
  • Quantum Interpretations and Foundations
Replies
12
Views
933
  • Engineering and Comp Sci Homework Help
Replies
8
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
5K
  • Advanced Physics Homework Help
Replies
3
Views
2K
  • Programming and Computer Science
Replies
7
Views
3K
  • Programming and Computer Science
Replies
18
Views
6K
  • Special and General Relativity
Replies
6
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
17
Views
2K
Back
Top