close

How to change pandas DataFrame.plot fontsize of xlabel?

Hello Guys, How are you all? Hope You all Are Fine. Today We Are Going To learn about How to change pandas DataFrame.plot fontsize of xlabel in Python. So Here I am Explain to you all the possible Methods here.

Without wasting your time, Let’s start This Article.

Table of Contents

How to change pandas DataFrame.plot fontsize of xlabel?

  1. How to change pandas DataFrame.plot fontsize of xlabel?

    plt.figure() The parameter 'plt.rcParams.update({'font.size': 36})' must set in the top.

  2. change pandas DataFrame.plot fontsize of xlabel

    plt.figure() The parameter 'plt.rcParams.update({'font.size': 36})' must set in the top.

Method 1

plt.figure() The parameter ‘plt.rcParams.update({‘font.size’: 36})’ must set in the top.

like this:

plt.figure()
plt.rcParams.update({'font.size': 22}) # must set in top

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.legend(loc=1,fontsize=20);
enter image description here

Because the ‘plt.rcParams’ is the default value.

The xlabel font maybe use ‘plt.rcParams’ when pandas.DataFrame.axes is bulit.

So ‘plt.rcParams’ should set in front of pandas.DataFrame.axes.

Summery

It’s all About this issue. Hope all Methods helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which Method worked for you? Thank You.

Also, Read