Just by using plt.ylabel(rotation='horizontal'), we can align a label according to our requirement.
Plot the lines using [0, 5] and [0, 5] lists.
Set the y-label for Y-axis, using ylabel method by passing rotation='horizontal'.
Set the x-label for X-axis, using xlabel method.
To show the plot, use plt.show() method.
from matplotlib import pyplot as plt plt.plot([0, 5], [0, 5]) plt.ylabel("Y-axis ", rotation='horizontal') plt.xlabel("X-axis ") plt.show()