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.Tick.have_units() Function
The Tick.have_units() function in axis module of matplotlib library is used to check whether the units are set on any axis.
Syntax: Tick.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.Tick.have_units() function in matplotlib.axis:
Example 1:
Python3
# Implementation of matplotlib function from matplotlib.axis import Tick import matplotlib.pyplot as plt import numpy as np from matplotlib.patches import Ellipse delta = 15.0 angles = np.arange( 0 , 360 + delta, delta) ells = [Ellipse(( 2 , 2 ), 5 , 2 , a) for a in angles] fig, ax = plt.subplots() for e in ells: Tick.set_clip_box(e, ax.bbox) e.set_facecolor( "green" ) e.set_alpha( 0.05 ) ax.add_artist(e) plt.xlim( - 1 , 5 ) plt.ylim( - 1 , 5 ) ax.set_title( "Units are set on any axis : " + str (Tick.have_units(ax.xaxis))) fig.suptitle('matplotlib.axis.Tick.have_units() \ function Example', fontweight = "bold" ) plt.show() |
Output:
Example 2:
Python3
# Implementation of matplotlib function from matplotlib.axis import Tick 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 = Tick.have_units(ax1.yaxis) print ( "Value Return by have_units() :" , w) fig.suptitle('matplotlib.axis.Tick.have_units() \ function Example', fontweight = "bold" ) plt.show() |
Output:
Value Return by have_units() : False