Wednesday, June 17, 2026
HomeLanguagesMatplotlib.axes.Axes.set_autoscale_on() in Python

Matplotlib.axes.Axes.set_autoscale_on() in Python

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_autoscale_on() Function

The Axes.set_autoscale_on() function in axes module of matplotlib library is used to set whether autoscaling is applied on plot commands.
 

Syntax: Axes.set_autoscale_on(self, b)
Parameters: This method accepts the following parameters. 
 

  • b: This parameter is used to whether to autoscaling is applied on plot commands or not.

Return value: This method does not return any value. 
 

Below examples illustrate the matplotlib.axes.Axes.set_autoscale_on() function in matplotlib.axes:
Example 1: 
 

Python3




# ImpleIn Reviewtation of matplotlib function 
import numpy as np
import matplotlib.pyplot as plt
 
xdata = np.linspace(16, 365, 300)
ydata = np.sin(2 * np.pi * xdata / 15) + np.cos(2 * np.pi * xdata / 17)
 
fig, ax = plt.subplots()
 
ax.plot(xdata, ydata, 'g-')
ax.set_autoscale_on(True)
 
fig.suptitle('matplotlib.axes.Axes.set_autoscale_on() function\
 Example\n', fontweight ="bold")
fig.canvas.draw()
plt.show()


Output: 
 

Example 2: 
 

Python3




# ImpleIn Reviewtation of matplotlib function 
import numpy as np
import matplotlib.pyplot as plt
 
xdata = np.linspace(16, 365, (365-16)*4)
ydata = np.sin(2 * np.pi * xdata / 153) + np.cos(2 * np.pi * xdata / 127)
 
fig, (ax, ax1) = plt.subplots(1, 2)
 
ax.plot(xdata, ydata, 'g-')
ax1.set_autoscale_on(True)
ax.set_title("set_autoscale_on value : True")
ax1.plot(xdata, ydata, 'g-')
ax1.set_autoscale_on(False)
ax1.set_title("set_autoscale_on value : False")
 
fig.suptitle('matplotlib.axes.Axes.set_autoscale_on() function \
Example\n', fontweight ="bold")
fig.canvas.draw()
plt.show()


Output: 
 

 

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32516 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6898 POSTS0 COMMENTS
Nicole Veronica
12014 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12109 POSTS0 COMMENTS
Shaida Kate Naidoo
7019 POSTS0 COMMENTS
Ted Musemwa
7262 POSTS0 COMMENTS
Thapelo Manthata
6976 POSTS0 COMMENTS
Umr Jansen
6964 POSTS0 COMMENTS