Matplotlib.axis.axis.get_data_interval()
matplotlib库Axis模块中的Axis.get_data_interval()函数用于获取该轴数据限制的Interval实例。
语法:Axis.get_data_interval(self)
参数:该方法不接受任何参数。
返回值:该方法返回此轴数据限制的Interval实例。
下面的例子说明了matplotlib.axis.axis.get_data_interval()函数在matplotlib.axis中的作用:
示例1
# 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()
输出:
Value return by get_data_interval() :
[ 0. 12.56637061]
示例2
# 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.]