# TH2 option TEXT not working with font 43

**URL:** <https://root-forum.cern.ch/t/th2-option-text-not-working-with-font-43/62513>\
**Category:** ROOT\
**Tags:** graphics, hist\
**Created:** [December 20, 2024, 1:54pm UTC](https://root-forum.cern.ch/t/th2-option-text-not-working-with-font-43/62513 "2024-12-20T13:54:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![pad](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/p/9fc348/32.png) [@pad](https://root-forum.cern.ch/u/pad)\
**Post date:** [December 20, 2024, 1:54pm UTC](https://root-forum.cern.ch/t/th2-option-text-not-working-with-font-43/62513/1 "2024-12-20T13:54:21Z")

</div>

Dear ROOT,

On my system, using the old canvas (TRootCanvas), the call to `TH2F::Draw("text")` do not show any bin content when the font is set to 13, 23 or 43…

This script reproduces the issue :

```python
def testH():
    h2 = ROOT.TH2F("h","h", 10, 0, 10, 10,0,10)
    h2.Fill(1,2,3)
    h2.Fill(1,1,0.2)
    h2.Fill(4,6,1.1)    
    h2.Draw("text")
    return h2

# in a python interactive session : 
h = testH() # --> ok bin contents are displayed as text
ROOT.gStyle.SetTextFont(43) # --> bin contents disapear
ROOT.gStyle.SetTextFont(42) # --> bin contents re-appear !

```

This problem does not occur with the new web-based canvas…  
Is there something I can do to fix the pbm ? (I’d like to use the exact same styling options as my collaborators…)

Cheers,  
P-A

* * *

_ROOT Version:_ 6.34.00  
_Platform:_ linuxx8664gcc  
_Compiler:_ (GCC) 14.2.1

* * *

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [December 20, 2024, 2:28pm UTC](https://root-forum.cern.ch/t/th2-option-text-not-working-with-font-43/62513/3 "2024-12-20T14:28:00Z")

</div>

I had a look. Indeed there is some fix to apply. The text, in that case, is drawn assuming a size in user coordinate (ie precision 2). If you set precision3 the size is in pixel but the histogram text painting method does not handle this case. A fix is needed.

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [December 20, 2024, 3:04pm UTC](https://root-forum.cern.ch/t/th2-option-text-not-working-with-font-43/62513/4 "2024-12-20T15:04:17Z")

</div>

Thanks to have seen this problem. This PR fixes it:

> <https://github.com/root-project/root/pull/17330>
>
> In THistPainter::PaintText the text precision must be 2 .
> This problem was ment…ion here https://root-forum.cern.ch/t/th2-option-text-not-working-with-font-43/62513

---

<div class="post-metadata">

**Author:** ![pad](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/p/9fc348/32.png) [@pad](https://root-forum.cern.ch/u/pad)\
**Post date:** [March 26, 2025, 4:52pm UTC](https://root-forum.cern.ch/t/th2-option-text-not-working-with-font-43/62513/5 "2025-03-26T16:52:41Z")

</div>

Hello,

I revive this thread because I see a similar problem also exist for the axis. Starting from the script above :

```python
h.GetXaxis().SetLabelFont(43)# --> labels disapear
h.GetXaxis().SetLabelFont(42)# --> labels re-apear

```

same thing with `h.GetXaxis().SetTitleFont(43)`

cheers,  
P-A

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [March 27, 2025, 2:36pm UTC](https://root-forum.cern.ch/t/th2-option-text-not-working-with-font-43/62513/8 "2025-03-27T14:36:54Z")

</div>

Indeed what you get is normal. When you specify the precision 3 the texte size should be specify in pixel. You need to do something like:

```auto
{
   TCanvas *C = new TCanvas("C","C",800,800);
   auto frame = gPad->DrawFrame(-4.,0.,4.,350);
   frame->GetXaxis()->SetLabelFont(43);
   frame->GetXaxis()->SetLabelSize(30);
}

```
