How to change the size of axis labels in Matplotlib? Last Updated : 15 Apr, 2025 Comments Improve Suggest changes Like Article Like Report Matplotlib is a Python library that helps in visualizing and customizing various plots. One of the customization you can do is to change the size of the axis labels to make reading easier. In this guide, we’ll look how to adjust font size of axis labels using Matplotlib.Let’s start with a basic plot to see how it works Python import matplotlib.pyplot as plt x = [1, 2, 3, 4, 5] y = [9, 8, 7, 6, 5] fig, ax = plt.subplots() ax.plot(x, y) ax.set_xlabel('x-axis') ax.set_ylabel('y-axis') plt.show() Output Sample Plot1. Using xlabel() and ylabel()We can change the size of axis labels by using the fontsize parameter in the xlabel() and ylabel() functions. These method allow you to specify the font size directly when setting the labels. Python import matplotlib.pyplot as plt x = [1, 2, 3, 4, 5] y = [9, 8, 7, 6, 5] fig, ax = plt.subplots() ax.plot(x, y) ax.plot(x, y) ax.set_xlabel('x-axis', fontsize = 25) ax.set_ylabel('y-axis', fontsize = 20) plt.show() Output:Resulting plot after adjusting axis label size in MatplotlibHere we defined x-axis font as 25 and y-axis font to be 20.2. Using set_xlabel() and set_ylabel()After plotting you can use set_xlabel() and set_ylabel() methods of the Axes object. These methods are used to modify labels after your plot has already been created. Python import matplotlib.pyplot as plt x = [1, 2, 3, 4, 5] y = [10, 20, 25, 30, 40] plt.plot(x, y) plt.gca().set_xlabel('Custom X-Axis Label', fontsize=20) plt.gca().set_ylabel('Custom Y-Axis Label', fontsize=20) plt.show() Output:Resulting output after adjusting axis label size in Matplotlib3. Changing Font Size Globally with rcParamsIf you require consistent font sizes across multiple plots adjusting the default settings with rcParams is a better approach. This method sets a global font size for all axis labels in your environment. Python import matplotlib as mpl import matplotlib.pyplot as plt mpl.rcParams['axes.labelsize'] = 20 x = [5, 10, 4, 2, 8] y = [49, 50, 90, 43, 87] plt.plot(x, y) plt.xlabel('Custom X-Axis Label') plt.ylabel('Custom Y-Axis Label') plt.show() Output:Resulting output after adjusting axis label size in MatplotlibAdjusting size of axis labels improves readability and understanding. Whether it's about sharing your plots with someone or just understanding the data alone proper label size makes your visuals better. Using the given ways you will can get neat, professional and clear charts. Comment More infoAdvertise with us Next Article How to change the size of axis labels in Matplotlib? ayushmankumar7 Follow Improve Article Tags : Python AI-ML-DS Python-matplotlib Practice Tags : python Similar Reads How to Change the Size of Figures in Matplotlib? Matplotlib provides a default figure size of 6.4 inches in width and 4.8 inches in height. While this is suitable for basic graphs, various situations may require resizing figures for better visualization, presentation or publication. This article explores multiple methods to adjust the figure size 3 min read How to Hide Axis Text Ticks or Tick Labels in Matplotlib? Matplotlib library in python shows axis ticks and tick labels by default. Sometimes it is important to hide these axis ticks and tick labels. In this article we will discuss some methods by which this can be done. Before that lets have a understanding about each of them:Ticks: Axes' points are marke 3 min read How to Set Tick Labels Font Size in Matplotlib? Prerequisite: MatplotlibMatplotlib is one of the most widely used data visualization libraries in Python. It provides a variety of ways to create high-quality 2D plots. One important aspect of making plots readable and aesthetically pleasing is formatting tick labels, including adjusting their font 3 min read How To Adjust Position of Axis Labels in Matplotlib? Matplotlib is a powerful Python library for creating graphs and charts. By default, it places axis labels in standard positions, but sometimes you might want to move them for better readability or design. This article explains easy ways to adjust the position of axis labels in Matplotlib to make you 3 min read How to change axes limits in matplotlib? Sometimes, when you create a plot default axes X and Y may not show the full picture you want. Changing the axes limits helps you focus on specific data ranges or improve how your plot looks. There are two methods available in Axes module tochange the limits:matplotlib.axes.Axes.set_xlim(): It is us 2 min read How to Change the Font Size of Colorbars in Matplotlib Matplotlib is a powerful and widely used library in Python for data visualization. It offers a variety of plotting functions to create complex graphs and charts. One common visualization is a heatmap, which often includes a color bar to indicate the scale of values represented by colors. Adjusting t 4 min read How to Rotate X-Axis Tick Label Text in Matplotlib? Matplotlib is an amazing and one of the most widely used data visualization libraries in Python for plots of arrays. It is a multi-platform data visualization library built on NumPy arrays and designed to work with the broader SciPy stack. It is much popular because of its customization options as w 3 min read How to change the font size of the Title in a Matplotlib figure ? In this article, we are going to discuss how to change the font size of the title in a figure using matplotlib module in Python. As we use matplotlib.pyplot.title() method to assign a title to a plot, so in order to change the font size, we are going to use the font size argument of the pyplot.title 2 min read How to set font size of Matplotlib axis Legend? Prerequisite: Matplotlib In this article, we will see how to set the font size of matplotlib axis legend using Python. For this, we will use rcParams() methods to increase/decrease the font size. To use this we have to override the matplotlib.rcParams['legend.fontsize'] method. Syntax: matplotlib.rc 1 min read Matplotlib.axis.Axis.set_label_text() function in Python Matplotlib is a library in Python and it is numerical â mathematical extension for NumPy library. It is an amazing visualization library in Python for 2D plots of arrays and used for working with the broader SciPy stack. Matplotlib.axis.Axis.set_label_text() Function The Axis.set_label_text() functi 2 min read Like