Thursday, June 11, 2026
HomeLanguagesMatplotlib.axis.Axis.remove_overlapping_locs() function in Python

Matplotlib.axis.Axis.remove_overlapping_locs() function in Python

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.remove_overlapping_locs Function

The Axis.remove_overlapping_locs function in axis module of matplotlib library is used to trim the minor ticker locations that overlap with major ticker locations.
 

Syntax: Axis.remove_overlapping_locs
 

Parameters: This method accepts the following parameters. 

  • formatter: This parameter is the locator.

Return value: This method does not returns any value. 

Below examples illustrate the matplotlib.axis.Axis.remove_overlapping_locs function in matplotlib.axis:

Example 1:

Python3




# Implementation of matplotlib function 
from matplotlib.axis import Axis
import matplotlib.pyplot as plt 
from matplotlib.ticker import MultipleLocator, ScalarFormatter 
     
fig, ax = plt.subplots() 
ax.plot([0, 5, 10, 15, 20], [3, 2, 1, 2, 4]) 
     
Axis.set_minor_locator(ax.xaxis, MultipleLocator(1)) 
Axis.set_minor_formatter(ax.xaxis, ScalarFormatter())
Axis.set_major_locator(ax.xaxis, MultipleLocator(4)) 
     
ax.tick_params(axis ='both', which ='major',  
               labelsize = 14, pad = 12,  
               colors ='g'
     
ax.tick_params(axis ='both', which ='minor'
               labelsize = 8, colors ='b')
ax.xaxis.remove_overlapping_locs
    
plt.title("Matplotlib.axis.Axis.remove_overlapping_locs \
Example", fontsize = 12, fontweight ='bold'
  
plt.show()


Output: 
 

Example 2:

Python3




# Implementation of matplotlib function 
from matplotlib.axis import Axis
import matplotlib.pyplot as plt 
import matplotlib.ticker as ticker
from matplotlib.ticker import MultipleLocator, ScalarFormatter
     
     
x = [0, 5, 9, 10, 15
y = [0, 1, 2, 3, 4
     
tick_spacing = 1
     
fig, ax = plt.subplots(1, 1
ax.plot(x, y)
  
Axis.set_major_locator(ax.xaxis, 
                       ticker.MultipleLocator(3))
Axis.set_minor_locator(ax.xaxis, 
                       ticker.MultipleLocator(tick_spacing))
Axis.set_minor_formatter(ax.xaxis, ScalarFormatter())
ax.xaxis.remove_overlapping_locs
    
plt.title("Matplotlib.axis.Axis.remove_overlapping_locs \
Example", fontsize = 12, fontweight ='bold'
  
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
32515 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6896 POSTS0 COMMENTS
Nicole Veronica
12012 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
6963 POSTS0 COMMENTS