小编Jia*_*Kui的帖子

如何更改xlabel的pandas DataFrame.plot fontsize?

我正在尝试用熊猫绘制图形。

可以设置其他文本的字体。

但是无法设置 xlabel。ax3 无法使用 axes.set_xlabel() 参数。

我也尝试 ax.set_fontsize() 或 plt.rcParams.update({'font.size': 22})。它不起作用。

    plt.figure()
    ax1 = df_plot.plot(x='wind_direct',y=plot_columns,figsize=(30,18),linewidth=5,kind='line',legend=True, fontsize=16)
    ax1.legend(loc=2,fontsize=20)
    ax1.set_ylabel('kw',fontdict={'fontsize':24})

    ax2 = ax1.twinx()
    ax3 = df_plot.plot(x='wind_direct',y=counts_columns,figsize=(30,18),kind='bar',legend=True, ax=ax2, fontsize=16)
    ax3.set_title(title,pad=20, fontdict={'fontsize':24})
    ax3.set_ylabel('counts',fontdict={'fontsize':24})
    #ax3.set_fontsize(24)
    plt.rcParams.update({'font.size': 22})
    ax3.legend(loc=1,fontsize=20);
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

python dataframe pandas

7
推荐指数
1
解决办法
1万
查看次数

标签 统计

dataframe ×1

pandas ×1

python ×1