Matplotlib.axes.axes.minorticks_off()
Matplotlib是Python中的一个库,它是NumPy库的数值-数学扩展。Axes包含了大多数图形元素:Axis、Tick、Line2D、Text、Polygon等,并设置坐标系。Axes的实例通过callbacks属性支持回调。
函数:Matplotlib.axes.axes.minorticks_off()
matplotlib库的Axes模块中的Axes.minorticks_off()函数用于删除轴上的小刻度。
语法:
Axes.minorticks_off(self)
注意:如果在使用minorticks_on()函数之后使用该函数,则该函数将显示任何更改或效果。
下面的例子演示了matplotlib.axes.axes.minorticks_off()函数在matplotlib.axes中的作用:
示例1
# 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()
输出:
示例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)
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()
输出: