Python中的 matplotlib.pyplot.minorticks_off()
Matplotlib是Python中的一个库,它是 NumPy 库的数值数学扩展。 Pyplot是Matplotlib模块的基于状态的接口,它提供了一个类似 MATLAB 的接口。
matplotlib.pyplot.minorticks_off()函数:
matplotlib 库的 pyplot 模块中的minorticks_off()函数用于从轴上删除次要刻度。
Syntax: matplotlib.pyplot.minorticks_off()
Parameters: This method does not accepts any parameters.
Return value: This method does not returns any value.
Note: This function will show any change or effect if it is used after use of minorticks_on() function.
下面的示例说明了 matplotlib.pyplot 中的 matplotlib.pyplot.minorticks_off()函数:
示例 #1:
# Implementation of matplotlib function
import numpy as np
import matplotlib.pyplot as plt
plt.minorticks_on()
np.random.seed(19680801)
mu, sigma = 100, 15
x = mu + sigma * np.random.randn(10000)
plt.hist(x, 150, density = True, facecolor ='g', alpha = 0.65)
plt.xlim(40, 160)
plt.ylim(0, 0.03)
plt.grid(True)
plt.minorticks_off()
plt.title('matplotlib.pyplot.minorticks_off() function Example',
fontweight ="bold")
plt.show()
输出:
示例 #2:
# 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)
plt.minorticks_on()
plt.fill_between(x, y1, y2, color ="green", alpha = 0.6)
plt.minorticks_off()
plt.title('matplotlib.pyplot.minorticks_off() function Example',
fontweight ="bold")
plt.show()
输出: