Python中的 Matplotlib.axis.Axis.set_view_interval()函数
Matplotlib是Python中的一个库,它是 NumPy 库的数值数学扩展。它是Python中用于数组二维图的惊人可视化库,用于处理更广泛的 SciPy 堆栈。
Matplotlib.axis.Axis.set_view_interval()函数
matplotlib 库的轴模块中的Axis.set_view_interval()函数用于设置轴视图限制。此方法仅供内部使用。
Syntax: Axis.set_view_interval(self, vmin, vmax, ignore=False)
Parameters: This method accepts the following parameters.
- vmin: This parameter is the minimum view limit.
- vmax: This parameter is the maximum view limit.
Return value: This method returns does not any value.
下面的示例说明了 matplotlib.axis 中的 matplotlib.axis.Axis.set_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)
ax.xaxis.set_view_interval(-2, 2 ,True)
ax.grid()
fig.suptitle("""matplotlib.axis.Axis.set_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, lw = 3)
ax.grid(True)
ax.xaxis.set_view_interval(-5 , 5)
fig.suptitle("""matplotlib.axis.Axis.set_view_interval()
function Example\n""", fontweight ="bold")
plt.show()
输出:
示例 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, lw = 3)
ax.grid(True)
ax.xaxis.set_view_interval(-5 , 5)
fig.suptitle("""matplotlib.axis.Axis.set_view_interval()
function Example\n""", fontweight ="bold")
plt.show()
输出: