Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Matplotlib.axes.Axes.set() in Python

  • Last Updated : 19 Apr, 2020

Matplotlib is a library in Python and it is numerical – mathematical extension for NumPy library. The Axes Class contains most of the figure elements: Axis, Tick, Line2D, Text, Polygon, etc., and sets the coordinate system. And the instances of Axes supports callbacks through a callbacks attribute.

matplotlib.axes.Axes.set() Function

The Axes.set() function in axes module of matplotlib library is a property batch setter. Pass kwargs to set properties.

Syntax: Axes.set(self, **kwargs)

Parameters: This method does not accepts any parameters other than **kwargs.

Below examples illustrate the matplotlib.axes.Axes.set() function in matplotlib.axes:

Example 1:




# Implementation of matplotlib function
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
   
t = np.arange(0.0, 2, 0.001)
s = 1 + np.sin(8 * np.pi * t)*0.4
   
fig, ax = plt.subplots()
ax.plot(t, s)
   
ax.set(xlabel ='X-Axis', ylabel ='Y-Axis',
       xlim =(0, 1.5), ylim =(0.5, 1.5),
       title ='matplotlib.axes.Axes.set()\
 function Example')
ax.grid()
   
plt.show()

Output:

Example 2:




# Implementation of matplotlib function
import numpy as np
import matplotlib.pyplot as plt
np.random.seed(19680801)
  
fig, ax = plt.subplots()
  
x, y, s, c = np.random.rand(4, 200)
s *= 200
  
ax.scatter(x, y, s, c)
  
ax.set(xlabel ='X-Axis', ylabel ='Y-Axis',
       xlim =(0, 0.5), ylim =(0, 0.5),
       title ='matplotlib.axes.Axes.set()\
 function Example')
ax.grid()
  
plt.show()

Output:

 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!