# Arviz plot\_ forrest()

**URL:** <https://discourse.pymc.io/t/arviz-plot-forrest/11155>\
**Category:** v5\
**Tags:** arviz\
**Created:** [January 10, 2023, 8:04pm UTC](https://discourse.pymc.io/t/arviz-plot-forrest/11155 "2023-01-10T20:04:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nn\_Nnn](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/nn_nnn/32/3790_2.png) [@Nn\_Nnn](https://discourse.pymc.io/u/Nn_Nnn)\
**Post date:** [January 10, 2023, 8:04pm UTC](https://discourse.pymc.io/t/arviz-plot-forrest/11155/1 "2023-01-10T20:04:46Z")

</div>

Using: PyMC v4.4.0: Arviz v0.14.0

Can anyone change the fontsize of the ‘model names’ on a az.plot\_forest() plot.

```auto
fig_0,ax=plt.subplots(1,3,figsize=(8.5,3))

az.plot_forest([idata_p,idata_p_sep],figsize=(8,3),var_names='mu',ax=ax[0],
               model_names=['Model_p','Model_p_sep_y'],textsize =10)

```

Nothing I tried has worked!

Has anybody found a method of reducing the textsize of the model names?  
thanking you in advance for trying. declan

---

<div class="post-metadata">

**Author:** ![guin0x](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/guin0x/32/5929_2.png) [@guin0x](https://discourse.pymc.io/u/guin0x)\
**Post date:** [January 14, 2023, 2:15pm UTC](https://discourse.pymc.io/t/arviz-plot-forrest/11155/2 "2023-01-14T14:15:08Z")

</div>

Hi,

I tried changing only the legend size from `plot_forest` but I didn’t find how…

However, since `az.plot_forest` is based on `matplotlib` you can change the global legend size of your notebook or code by running the following

```auto
import matplotlib.pyplot as plt
plt.rc('legend', fontsize=5)

```

note that this will change the size of the text in **ALL** legends that you plot after running the code.

---

<div class="post-metadata">

**Author:** ![Nn\_Nnn](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/nn_nnn/32/3790_2.png) [@Nn\_Nnn](https://discourse.pymc.io/u/Nn_Nnn)\
**Post date:** [January 14, 2023, 3:03pm UTC](https://discourse.pymc.io/t/arviz-plot-forrest/11155/3 "2023-01-14T15:03:24Z")

</div>

> [@guin0x](#):
>
> `plt.rc('legend', fontsize=5)`

Thanks for your reply. yes this changes all the fonts but labels and title fonts can then be independently increased using: ax[0].set\_ylabel(‘Posterior Parameters Hdi=95%’,fontsize=10)  
ax[0].set\_title(‘Posterior Parameters Hdi=95%’,fontsize=18). Surprisingly, there does not seem direct way to achieve model labels alone, this, so your method / solution is appreciated. Declan

---

<div class="post-metadata">

**Author:** ![OriolAbril](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/oriolabril/32/2497_2.png) [@OriolAbril](https://discourse.pymc.io/u/OriolAbril)\
**Post date:** [January 15, 2023, 10:57pm UTC](https://discourse.pymc.io/t/arviz-plot-forrest/11155/4 "2023-01-15T22:57:18Z")

</div>

You can modify the text instances of the legend items with the following code:

```python
legend = ax[0].get_legend() 
for text in legend.get_texts():
    text.set(fontsize=9, color="r")

```

Note you can set fontsize only to modify it, or any other property of the text. [matplotlib.text — Matplotlib 3.6.3 documentation](https://matplotlib.org/stable/api/text_api.html#matplotlib.text.Text.set) has all the properties you can modify like this.

---

<div class="post-metadata">

**Author:** ![Nn\_Nnn](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/nn_nnn/32/3790_2.png) [@Nn\_Nnn](https://discourse.pymc.io/u/Nn_Nnn)\
**Post date:** [January 16, 2023, 10:32am UTC](https://discourse.pymc.io/t/arviz-plot-forrest/11155/5 "2023-01-16T10:32:03Z")

</div>

> [@OriolAbril](#):
>
> ```auto
> legend = ax[0].get_legend() 
> for text in legend.get_texts():
> text.set(fontsize=9, color="r")
> 
> ```

Thanks, it works brillantly !  
Declan
