简体   繁体   English

seaborn中轴标签的字体大小

[英]Font size of axis labels in seaborn

In seaborn, how can you change just the x and y axis label font size? 在seaborn中,如何更改x和y轴标签字体大小? Instead of using the "set context" method, is there a way to specifically change just the axis labels? 而不是使用“设置上下文”方法,有没有办法专门更改轴标签? Here is my code: 这是我的代码:

def corrfunc(x, y, **kws):

    r = stats.pearsonr(x, y)[0] ** 2
    ax = plt.gca()
    ax.annotate("r$^2$ = {:.2f}".format(r),
                xy=(.1, .9), xycoords=ax.transAxes, fontsize=16)
    if r > 0.6:
        col = 'g'
    elif r < 0.6:
        col = 'r'
    sns.regplot(x, y, color=col)
    return r

IC_Plot = sns.PairGrid(df_IC, palette=["red"])
IC_Plot.map_offdiag(corrfunc)

IC_Plot.savefig("Save_Pair.png")

The easiest way to change the fontsize of all x- and y- labels in a plot is to use the rcParams property "axes.labelsize" at the beginning of the script, eg 更改绘图中所有x和y标签的字体大小的最简单方法是在脚本开头使用rcParams属性"axes.labelsize" ,例如

plt.rcParams["axes.labelsize"] = 15

You may also set the font size of each individual label 您还可以设置每个标签的字体大小

for ax in plt.gcf().axes:
    l = ax.get_xlabel()
    ax.set_xlabel(l, fontsize=15)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM