Open In App

Matplotlib.axes.Axes.set() in Python

Improve
Improve
Like Article
Like
Save
Share
Report

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:



Last Updated : 19 Apr, 2020
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads