Arviz plot_ forrest()

Using: PyMC v4.4.0: Arviz v0.14.0

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


               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


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

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.

1 Like

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

1 Like

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

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 has all the properties you can modify like this.

Thanks, it works brillantly !