# vtkLegendBoxActor is not supportting to set text font size

**URL:** https://discourse.vtk.org/t/vtklegendboxactor-is-not-supportting-to-set-text-font-size/10898
**Category:** Support
**Tags:** python
**Created:** [March 6, 2023, 6:06am UTC](https://discourse.vtk.org/t/vtklegendboxactor-is-not-supportting-to-set-text-font-size/10898 "2023-03-06T06:06:25Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Jishnu](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jishnu/32/6221_2.png) [@Jishnu](https://discourse.vtk.org/u/Jishnu)
#### Post date: [March 6, 2023, 6:06am UTC](https://discourse.vtk.org/t/vtklegendboxactor-is-not-supportting-to-set-text-font-size/10898/1 "2023-03-06T06:06:25Z")

</div>

Hi,

I am using vtkLegendBoxActor to show legends in a plot. However, I am unable to control the font size of text in the legend.  
I have tried the following:

```auto
legendActor=vtkLegendBoxActor()
textProp=vtkTextProperty()
textProp.SetFontSize(3)
textProp.SetVerticalJustificationToCentered()
legendActor.SetEntryTextProperty(textProp)

```

However, this seems not set the font size of the text. It still appears the default size of 12. I have checked the font size after setting the property as:

```auto
legendActor.GetEntryTextProperty().GetFontSize()

```

Which returns 3. Please help me to fix the issue.

Thank you.

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [March 7, 2023, 2:12pm UTC](https://discourse.vtk.org/t/vtklegendboxactor-is-not-supportting-to-set-text-font-size/10898/2 "2023-03-07T14:12:27Z")

</div>

Hello,

Creating and setting composition objects is generally not advised in VTK. I’d simply do

```python
legendActor.GetEntryTextProperty().SetFontSize(3)

```

take care,

Paulo

---

<div class="post-metadata">

### Author: ![Jishnu](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jishnu/32/6221_2.png) [@Jishnu](https://discourse.vtk.org/u/Jishnu)
#### Post date: [March 14, 2023, 3:31am UTC](https://discourse.vtk.org/t/vtklegendboxactor-is-not-supportting-to-set-text-font-size/10898/3 "2023-03-14T03:31:14Z")

</div>

Hi Paulo,  
I tried it, but not working. I checked the source code and found that the font size is by default set to 12. And when user resizes the window, the font size is further adjusted to fit in the ‘Legend Box’.

Thank you,  
Jishnu

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [March 14, 2023, 1:47pm UTC](https://discourse.vtk.org/t/vtklegendboxactor-is-not-supportting-to-set-text-font-size/10898/4 "2023-03-14T13:47:26Z")

</div>

Hi,

Please, try `legendActor.LockBorderOff()` and then set font size.

best,

PC

---

<div class="post-metadata">

### Author: ![Jishnu](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jishnu/32/6221_2.png) [@Jishnu](https://discourse.vtk.org/u/Jishnu)
#### Post date: [March 15, 2023, 3:30am UTC](https://discourse.vtk.org/t/vtklegendboxactor-is-not-supportting-to-set-text-font-size/10898/5 "2023-03-15T03:30:57Z")

</div>

Hi Paulo Carvalho,  
Thank you for the answer. This is working.
