Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

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

  • Last Updated : 08 Jun, 2020

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.have_units() Function

The Axis.have_units() function in axis module of matplotlib library is used to check whether the units are set on any axis. 
 

 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course

Syntax: Axis.have_units(self) 
 



Parameters: This method does not accepts any parameter. 
 

Return value: This method return True if units are set on any axis. 

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

Example 1:

Python3




# Implementation of matplotlib function
from matplotlib.axis import Axis
import matplotlib.pyplot as plt 
     
fig, axs = plt.subplots() 
axs.plot([1, 2, 3]) 
    
axs.set_title("Units are set on any axis : "
              +str(axs.xaxis.have_units()))   
  
fig.suptitle('matplotlib.axis.Axis.have_units() \
function Example\n', fontweight ="bold")  
    
plt.show() 

Output: 

Example 2:

Python3




# Implementation of matplotlib function
from matplotlib.axis import Axis
import matplotlib.pyplot as plt 
      
fig, ax1 = plt.subplots( ) 
ax1.set_xscale("log"
ax1.set_yscale("log"
ax1.set_adjustable("datalim"
    
ax1.plot([1, 3, 34, 4, 46, 3, 7, 45, 10], 
         [1, 9, 27, 8, 29, 84, 78, 19, 48], 
          "o-", color ="green"
    
ax1.set_xlim(1e-1, 1e2
ax1.set_ylim(1, 1e2
    
w = Axis.have_units(ax1.yaxis) 
    
print("Value Return by have_units() :", w)   
  
fig.suptitle('matplotlib.axis.Axis.have_units() \
function Example\n', fontweight ="bold")  
    
plt.show() 

Output: 

 




My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!