Matplotlib.axis.Axis.reset_ticks() function in Python
Last Updated :
08 Jun, 2020
Improve
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.reset_ticks() Function
The Axis.reset_ticks() function in axis module of matplotlib library is used to re-initialize the major and minor Tick lists.
Syntax: Axis.reset_ticks(self)
Parameters: This method does not accepts any parameter.
Return value: This method does not return any value.
Below examples illustrate the matplotlib.axis.Axis.reset_ticks() function in matplotlib.axis:
Example 1:
- Python3
Python3
# Implementation of matplotlib function from matplotlib.axis import Axis import matplotlib.pyplot as plt import matplotlib.colors as mcolors import matplotlib.gridspec as gridspec import numpy as np plt.rcParams[ 'savefig.facecolor' ] = "0.8" plt.rcParams[ 'figure.figsize' ] = 6 , 5 fig, ax = plt.subplots() ax.plot([ 1 , 2 ]) ax.locator_params( "x" ,nbins = 3 ) ax.locator_params( "y" ,nbins = 5 ) ax.set_xlabel( 'x-label' ) ax.set_ylabel( 'y-label' ) ax.yaxis.reset_ticks() ax.grid() fig.suptitle( """matplotlib.axis.Axis.reset_ticks() function Example\n""" , fontweight = "bold") plt.show() |
Output:
Example 2:
- Python3
Python3
# Implementation of matplotlib function from matplotlib.axis import Axis import numpy as np import matplotlib.pyplot as plt import matplotlib.transforms as mtransforms delta = 0.5 x = y = np.arange( - 2.0 , 4.0 , delta) X, Y = np.meshgrid(x * * 2 , y) Z1 = np.exp( - X * * 2 - Y * * 2 ) Z2 = np.exp( - (X - 1 ) * * 2 - (Y - 1 ) * * 2 ) Z = (Z1 - Z2) transform = mtransforms.Affine2D().rotate_deg( 30 ) fig, ax = plt.subplots() im = ax.imshow(Z, interpolation = 'none' , origin = 'lower' , extent = [ - 2 , 4 , - 3 , 2 ], clip_on = True ) trans_data = transform + ax.transData Axis.set_transform(im, trans_data) x1, x2, y1, y2 = im.get_extent() ax.plot([x1, x2, x2, x1, x1], [y1, y1, y2, y2, y1], "ro-" , transform = trans_data) ax.set_xlim( - 5 , 5 ) ax.set_ylim( - 4 , 4 ) ax.yaxis.reset_ticks() ax.grid() fig.suptitle( """matplotlib.axis.Axis.reset_ticks() function Example\n""" , fontweight = "bold") plt.show() |
Output: