Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Matplotlib.pyplot.ylabel() in Python

  • Last Updated : 12 Apr, 2020

Matplotlib is a very powerful plotting library useful for those working with Python and NumPy. And for making statistical interference, it becomes very necessary to visualize our data and Matplotlib is the tool that can be very helpful for this purpose.

matplotlib.pyplot.ylabel()

This function sets the label for the y-axis of the plot.

Syntax: matplotlib.pyplot.ylabel(ylabel, fontdict=None, labelpad=None)

Parameters:
ylabel: The name of the label
fontdict: Adds the font styles to the label
labelpad: This helps us to set the spacing between label and the axis

Example #1:




import matplotlib.pyplot as plt
  
# setting x values
x =['Geeks', 'for', 'geeks', 'tutorials']
  
# Setting y values 
y =[1, 2, 3, 4]
  
# Adding label on the y-axis
plt.ylabel('Numbers label')
  
# plotting the graph
plt.plot(x, y)

Output:

matplotlib.pyplot.ylabel()

Example #2:




import matplotlib.pyplot as plt
  
x =['Geeks', 'for', 'geeks', 'tutorials']
y =[1, 2, 3, 4]
  
# Adding space between label and
# axis by setting labelpad
plt.ylabel('Numbers label', labelpad = 50)
  
plt.plot(x, y)

Output:

matplotlib.pyplot.ylabel()

Example #3:




import matplotlib.pyplot as plt
  
x =['Geeks', 'for', 'geeks', 'tutorials']
y =[1, 2, 3, 4]
  
# Setting font dictionary 
font = {'family': 'Verdana',
        'color''green',
        'size': 20,
        }
  
# Adding the font styles to the label
plt.ylabel('Numbers label', fontdict = font)
  
plt.plot(x, y)

Output:
matplotlib.pyplot.ylabel()


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!