我想知道如何在我制作的循环中增加所有子图中的字体大小。我计划同时绘制所有组的箱线图,每个图代表数据集中的一个数值变量。
fig, axes = plt.subplots(6,6,figsize = (60,60))
for i in range (37):
if i != 0:
xi = df.iloc[:,i]
a = (i-1) % 6
if i <= 6:
b = 0
elif i > 6 and i <= 12:
b = 1
elif i > 12 and i <= 18:
b = 2
elif i > 18 and i <= 24:
b = 3
elif i > 24 and i <= 30:
b = 4
else:
b = 5
sns.boxplot(x=xi, y="POI", data=df, orient="h",ax = axes[a,b])
plt.show()
我在循环中试过这个:
plt.yticks(fontsize=15)
plt.xticks(fontsize=15)
plt.ylabel('XX', size = 20)
plt.xlabel('XXX', size = 20)
但它只改变了最后一个子图,而不是全部。
一个不错的方法是使用绘图上下文:
with sns.plotting_context("notebook", font_scale=1.5):
# put all your plotting code here
您可以将其更改font_scale
为您喜欢的任何内容。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句