Friday, December 12, 2025
HomeLanguagesMatplotlib.axis.Axis.set_minor_formatter() function in Python

Matplotlib.axis.Axis.set_minor_formatter() 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.set_minor_formatter() Function

The Axis.set_minor_formatter() function in axis module of matplotlib library is used to set the formatter of the minor ticker.
 

Syntax: Axis.set_minor_formatter(self, formatter)

Parameters: This method accepts the following parameters. 

  • formatter: This parameter is the Formatter.

Return value: This method does not returns any value. 

Below examples illustrate the matplotlib.axis.Axis.set_minor_formatter() 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()) 
    
ax.tick_params(axis ='both', which ='major',  
               labelsize = 14, pad = 12,  
               colors ='g'
    
ax.tick_params(axis ='both', which ='minor'
               labelsize = 8, colors ='b'
   
plt.title("Matplotlib.axis.Axis.set_minor_formatter()\n\
Function 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 
from matplotlib.ticker import LogFormatter 
import numpy as np 
    
fig, axes = plt.subplots(2
    
dt = 0.01
t = np.arange(dt, 20.0, dt) 
    
# first plot doesn't use a formatter 
axes[0].semilogx(t, np.exp(-t / 5.0))  
axes[0].grid() 
    
xlims = [[0, 25], [0.2, 8], [0.6, 0.9]] 
    
for ax, xlim in zip(axes[1:], xlims): 
    
    ax.semilogx(t, np.exp(-t / 5.0)) 
    formatter = LogFormatter(labelOnlyBase = False,  
                             minor_thresholds = (2, 0.4)) 
    
    Axis.set_minor_formatter(ax.xaxis, formatter)  
    ax.grid() 
  
fig.suptitle("Matplotlib.axis.Axis.set_minor_formatter()\n\
Function 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
32444 POSTS0 COMMENTS
Milvus
105 POSTS0 COMMENTS
Nango Kala
6813 POSTS0 COMMENTS
Nicole Veronica
11951 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12026 POSTS0 COMMENTS
Shaida Kate Naidoo
6945 POSTS0 COMMENTS
Ted Musemwa
7197 POSTS0 COMMENTS
Thapelo Manthata
6891 POSTS0 COMMENTS
Umr Jansen
6881 POSTS0 COMMENTS