Nn_Nnn
January 10, 2023, 8:04pm
1
Using: PyMC v4.4.0: Arviz v0.14.0
Can anyone change the fontsize of the ‘model names’ on a az.plot_forest() plot.
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
guin0x
January 14, 2023, 2:15pm
2
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
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
Nn_Nnn
January 14, 2023, 3:03pm
3
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.
Nn_Nnn
January 16, 2023, 10:32am
5
Thanks, it works brillantly !
Declan