Python中的 Matplotlib.axis.Axis.get_view_interval()函数
Matplotlib是Python中的一个库,它是 NumPy 库的数值数学扩展。它是Python中用于二维数组图的惊人可视化库,用于处理更广泛的 SciPy 堆栈。
Matplotlib.axis.Axis.get_view_interval()函数
matplotlib 库的轴模块中的Axis.get_view_interval()函数用于获取该轴的视图限制(最小值,最大值)。
Syntax: Axis.get_view_interval(self)
Parameters: This method does not accepts any parameters.
Return value: This method returns the view limits (min, max) of this axis.
下面的示例说明了 matplotlib.axis 中的 matplotlib.axis.Axis.get_view_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_view_interval() :")
w = ax.xaxis.get_view_interval()
print(w)
ax.grid()
fig.suptitle("""matplotlib.axis.Axis.get_view_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_view_interval() :")
w = ax.xaxis.get_view_interval()
print(w)
fig.suptitle("""matplotlib.axis.Axis.get_view_interval()
function Example\n""", fontweight ="bold")
plt.show()
输出:
Value return by get_view_interval() :
[-0.62831853 13.19468915]
示例 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_view_interval() :")
w = ax.xaxis.get_view_interval()
print(w)
fig.suptitle("""matplotlib.axis.Axis.get_view_interval()
function Example\n""", fontweight ="bold")
plt.show()
输出:
Value return by get_view_interval() :
[-22. 22.]