Open In App

Matplotlib.axis.Axis.limit_range_for_scale() function 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. It is an amazing visualization library in Python for 2D plots of arrays and used for working with the broader SciPy stack.

Matplotlib.axis.Axis.limit_range_for_scale() Function

The Axis.limit_range_for_scale() function in axis module of matplotlib library is used to re-initialize the major and minor Tick lists. 
 

Syntax: Axis.limit_range_for_scale(self, vmin, vmax) 
 

Parameters: This method accepts the following parameters. 

  • vmin: This parameter is the minimum value.
  • vmax: This parameter is the maximum value.

Return value: This method does not return any value. 

Below examples illustrate the matplotlib.axis.Axis.limit_range_for_scale() function in matplotlib.axis:
 

Example 1:

Python3




# Implementation of matplotlib function
from matplotlib.axis import Axis
import matplotlib.pyplot as plt
   
fig, ax = plt.subplots()
   
ax.set_yscale("log")
ax.set_adjustable("datalim")
ax.plot([1, 3, 10], [1, 9, 100], "o-",color="green")
ax.set_aspect(1)
  
ax.xaxis.limit_range_for_scale(0,5)
   
ax.grid() 
   
fig.suptitle("""matplotlib.axis.Axis.limit_range_for_scale()
function Example\n""", fontweight ="bold")  
     
plt.show()


Output: 
 

Example 2:

Python3




# Implementation of matplotlib function
from matplotlib.axis import Axis
import numpy as np
import matplotlib.pyplot as plt
   
   
fig, ax4 = plt.subplots()
   
x = 10.0**np.linspace(0.0, 2.0, 15)
y = x**2.0
ax4.set_xscale("log", nonposx='clip')
ax4.set_yscale("log", nonposy='clip')
   
ax4.errorbar(x, y, xerr=0.1 * x, 
             yerr=2.0 + 1.75 * y,
             color="green")
   
ax4.set_ylim(bottom=0.1)
  
ax4.xaxis.limit_range_for_scale(0,5)
ax4.yaxis.limit_range_for_scale(3,5)
   
ax4.grid() 
   
fig.suptitle("""matplotlib.axis.Axis.limit_range_for_scale()
function Example\n""", fontweight ="bold")  
     
plt.show()


Output: 
 

 



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