- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to set my xlabel at the end of X-axis in Matplotlib?
To set the xlabel at the end of X-axis in matplotlib, we can take the following steps −
Create data points for x using numpy.
Using subplot() method, add a subplot to the current figure.
Plot x and log(x) using plot() method.
Set the label on X-axis using set_label() method, with fontsize=16, loc=left, and color=red.
To set the xlabel at the end of X-axis, use the coordinates, x and y.
To display the figure, use show() method.
Example
import numpy as np from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True x = np.linspace(1, 2, 5) ax = plt.subplot() ax.plot(x, np.log(x)) ax.set_xticks(x) label = ax.set_xlabel('X ->', fontsize=16, loc="left", c="red") ax.xaxis.set_label_coords(1.0, -0.025) plt.show()
Output
- Related Articles
- How to set "step" on axis X in my figure in Matplotlib Python 2.6.6?
- How to set X-axis values in Matplotlib Python?
- How to customize the X-axis in Matplotlib?
- How to set the value of the axis multiplier in matplotlib?
- How to add a second X-axis at the bottom of the first one in Matplotlib?
- How to set the unit length of an axis in Matplotlib?
- How to change the range of the X-axis and Y-axis in Matplotlib?
- How to set the font size of Matplotlib axis Legend?
- How to annotate a range of the X-axis in Matplotlib?
- How to customize X-axis ticks in Matplotlib?
- How to set the X-axis labels in histogram using ggplot2 at the center in R?
- How to set axis ticks in multiples of pi in Python Matplotlib?
- How to add a second X-axis in Matplotlib?
- How to shift a graph along the X-axis in matplotlib?
- How to add footnote under the X-axis using Matplotlib?

Advertisements