Python中的 Matplotlib.axis.Axis.get_major_locator()函数
Matplotlib是Python中的一个库,它是 NumPy 库的数值数学扩展。它是Python中用于二维数组图的惊人可视化库,用于处理更广泛的 SciPy 堆栈。
matplotlib.axis.Axis.get_major_locator()函数
matplotlib 库的轴模块中的Axis.get_major_locator()函数用于获取主要股票代码的定位器。
Syntax: Axis.get_major_locator(self)
Parameters: This method does not accepts any parameters.
Return value: This method returns the locator of the major ticker.
下面的示例说明了 matplotlib.axis 中的 matplotlib.axis.Axis.get_major_locator()函数:
示例 1:
Python3
# Implementation of matplotlib function
import numpy as np
from matplotlib.axis import Axis
import matplotlib.pyplot as plt
x = np.linspace(0, 10, 1000)
y = np.sin(2 * x)
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(x, y)
ax.grid()
print(Axis.get_major_locator(ax.yaxis))
plt.title("Matplotlib.axis.Axis.get_major_locator()\n\
Function Example", fontsize = 12, fontweight ='bold')
plt.show()
Python3
# Implementation of matplotlib function
import numpy as np
from matplotlib.axis import Axis
import matplotlib.pyplot as plt
np.random.seed(19680801)
fig, ax = plt.subplots()
x, y, s, c = np.random.rand(4, 100)
s *= 100
ax.scatter(x, y, s, c)
ax.grid()
print(Axis.get_major_locator(ax.xaxis))
plt.title("Matplotlib.axis.Axis.get_major_locator()\n\
Function Example", fontsize = 12, fontweight ='bold')
plt.show()
输出:
示例 2:
Python3
# Implementation of matplotlib function
import numpy as np
from matplotlib.axis import Axis
import matplotlib.pyplot as plt
np.random.seed(19680801)
fig, ax = plt.subplots()
x, y, s, c = np.random.rand(4, 100)
s *= 100
ax.scatter(x, y, s, c)
ax.grid()
print(Axis.get_major_locator(ax.xaxis))
plt.title("Matplotlib.axis.Axis.get_major_locator()\n\
Function Example", fontsize = 12, fontweight ='bold')
plt.show()
输出: