Open In App

Matplotlib.axes.Axes.minorticks_off() in Python

Last Updated : 21 Apr, 2020
Comments
Improve
Suggest changes
Like Article
Like
Report
Matplotlib is a library in Python and it is numerical - mathematical extension for NumPy library. The Axes Class contains most of the figure elements: Axis, Tick, Line2D, Text, Polygon, etc., and sets the coordinate system. And the instances of Axes supports callbacks through a callbacks attribute.

matplotlib.axes.Axes.minorticks_off() Function

The Axes.minorticks_off() function in axes module of matplotlib library is used to remove minor ticks on the axes. Syntax:
Axes.minorticks_off(self)
Note: This function will show any change or effect if it is used after use of minorticks_on() function. Below examples illustrate the matplotlib.axes.Axes.minorticks_off() function in matplotlib.axes: Example 1: Python3
# Implementation of matplotlib function
import numpy as np
import matplotlib.pyplot as plt
 
fig, ax1 = plt.subplots()

ax1.minorticks_on()

np.random.seed(19680801)
mu, sigma = 100, 15
x = mu + sigma * np.random.randn(10000)

ax1.hist(x, 50, density = True, facecolor ='g',
         alpha = 0.65)

ax1.set_xlim(40, 160)
ax1.set_ylim(0, 0.03)
plt.grid(True)

ax1.minorticks_off()
fig.suptitle('matplotlib.axes.Axes.minorticks_off()\
 function Example\n\n', fontweight ="bold")
plt.show()
Output: Example 2: Python3
# Implementation of matplotlib function
import matplotlib.pyplot as plt
import numpy as np

x = np.arange(0.0, 2, 0.01)
y1 = np.sin(2 * np.pi * x)
y2 = 1.2 * np.sin(4 * np.pi * x)

fig, (ax, ax1) = plt.subplots(1, 2)

ax.minorticks_on()
ax1.minorticks_on()


ax.fill_between(x, y1, y2, color ="green", 
                alpha = 0.6)
ax.set_title("Without minorticks_off()")

ax1.fill_between(x, y1, y2, color ="green",
                 alpha = 0.6)
ax1.set_title("With minorticks_off()")
ax1.minorticks_off()

fig.suptitle('matplotlib.axes.Axes.minorticks_off() \
function Example\n\n', fontweight ="bold")
plt.show()
Output:

Next Article
Article Tags :
Practice Tags :

Similar Reads