Python中的 Matplotlib.axis.Axis.get_data_interval()函数
Matplotlib是Python中的一个库,它是 NumPy 库的数值数学扩展。它是Python中用于二维数组图的惊人可视化库,用于处理更广泛的 SciPy 堆栈。
Matplotlib.axis.Axis.get_data_interval()函数
matplotlib 库的轴模块中的Axis.get_data_interval()函数用于获取此轴数据限制的间隔实例。
Syntax: Axis.get_data_interval(self)
Parameters: This method does not accepts any parameters.
Return value: This method returns the Interval instance for this axis data limits.
下面的示例说明了 matplotlib.axis 中的 matplotlib.axis.Axis.get_data_interval()函数:
示例 1:
Python3
# Implementation of matplotlib function
from matplotlib.axis import Axis
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure()
x = np.linspace(0,4*np.pi,100)
y = 2*np.sin(x)
ax = fig.add_subplot()
ax.plot(x,y)
print("Value return by get_data_interval() :")
w = ax.xaxis.get_data_interval()
print(w)
ax.grid()
fig.suptitle("""matplotlib.axis.Axis.get_data_interval()
function Example\n""", fontweight ="bold")
plt.show()
Python3
# Implementation of matplotlib function
from matplotlib.axis import Axis
import matplotlib.pyplot as plt
import numpy as np
np.random.seed(10**7)
geeks = np.random.randn(40)
fig, ax = plt.subplots()
ax.acorr(geeks, usevlines = True,
normed = True,
maxlags = 20, lw = 3)
ax.grid(True)
print("Value return by get_data_interval() :")
w = ax.xaxis.get_data_interval()
print(w)
fig.suptitle("""matplotlib.axis.Axis.get_data_interval()
function Example\n""", fontweight ="bold")
plt.show()
输出:
Value return by get_data_interval() :
[ 0. 12.56637061]
示例 2:
Python3
# Implementation of matplotlib function
from matplotlib.axis import Axis
import matplotlib.pyplot as plt
import numpy as np
np.random.seed(10**7)
geeks = np.random.randn(40)
fig, ax = plt.subplots()
ax.acorr(geeks, usevlines = True,
normed = True,
maxlags = 20, lw = 3)
ax.grid(True)
print("Value return by get_data_interval() :")
w = ax.xaxis.get_data_interval()
print(w)
fig.suptitle("""matplotlib.axis.Axis.get_data_interval()
function Example\n""", fontweight ="bold")
plt.show()
输出:
Value return by get_data_interval() :
[-20. 20.]