Matplotlib.axis.axis.get_tick_space()
matplotlib库的Axis模块中的Axis.get_tick_space()函数用于获取可以装入该轴的滴答数的估计值。
语法:Axis.get_tick_space(self)
参数:该方法不接受任何参数。
返回值:该方法返回轴上可容纳的刻度的估计数量。
下面的例子说明了matplotlib.axis.axis.get_tick_space()函数在matplotlib.axis中的作用:
示例1
# Implementation of matplotlib function
from matplotlib.axis import Axis
import matplotlib.pyplot as plt
import numpy as np
X = np.arange(-5, 5, 1)
Y = np.arange(-5, 5, 1)
U, V = np.meshgrid(X, Y)
fig, ax = plt.subplots()
ax.quiver(X, Y, U, V)
w = ax.xaxis.get_tick_space()
print("Value Return :\n"+str(w))
fig.suptitle("""matplotlib.axis.Axis.get_tick_space()
function Example\n""", fontweight ="bold")
plt.show()
输出:
Value Return :
11
示例2
# Implementation of matplotlib function
from matplotlib.axis import Axis
import numpy as np
import matplotlib.pyplot as plt
fig, ax2 = plt.subplots(sharex = True)
fig.subplots_adjust(left=0.2, wspace=0.6)
box = dict(facecolor='green', pad=5, alpha=0.2)
ax2.plot(20*np.random.rand(10))
ax2.set_xlabel('X - Label', bbox=box)
ax2.set_xlim(0, 10)
Axis.set_label_coords(ax2.xaxis, 0.5, 0.95)
w = ax2.xaxis.get_tick_space()
print("Value Return :\n"+str(w))
fig.suptitle("""matplotlib.axis.Axis.get_tick_space()
function Example\n""", fontweight ="bold")
plt.show()
输出:
Value Return :
10