Python中的 Matplotlib.axis.Axis.pan()函数
Matplotlib是Python中的一个库,它是 NumPy 库的数值数学扩展。它是Python中用于二维数组图的惊人可视化库,用于处理更广泛的 SciPy 堆栈。
Matplotlib.axis.Axis.pan()函数
matplotlib 库的轴模块中的Axis.pan()函数用于按 numsteps 平移。
Syntax: Axis.pan(self, numsteps)
Parameters: This method accepts the following parameters.
- numsteps: This parameter is the value(positive or negative).
Return value: This method does not return any value.
下面的示例说明了 matplotlib.axis 中的 matplotlib.axis.Axis.pan()函数:
示例 1:
Python3
# Implementation of matplotlib function
from matplotlib.axis import Axis
import matplotlib.pyplot as plt
import numpy as np
fig, ax = plt.subplots()
ax.plot([1, 2, 3])
ax.xaxis.pan(3)
ax.grid()
fig.suptitle("""matplotlib.axis.Axis.pan()
function Example\n""", fontweight ="bold")
plt.show()
Python3
# Implementation of matplotlib function
from matplotlib.axis import Axis
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.widgets import Slider, Button, RadioButtons
fig, ax1 = plt.subplots()
plt.subplots_adjust(bottom = 0.25)
t = np.arange(0.0, 1.0, 0.001)
a0 = 5
f0 = 3
delta_f = 5.0
s = a0 * np.sin(2 * np.pi * f0 * t)
ax1.plot(t, s, lw = 2, color = 'green')
ax1.xaxis.pan(-2)
ax1.grid()
fig.suptitle("""matplotlib.axis.Axis.pan()
function Example\n""", fontweight ="bold")
plt.show()
输出:
示例 2:
Python3
# Implementation of matplotlib function
from matplotlib.axis import Axis
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.widgets import Slider, Button, RadioButtons
fig, ax1 = plt.subplots()
plt.subplots_adjust(bottom = 0.25)
t = np.arange(0.0, 1.0, 0.001)
a0 = 5
f0 = 3
delta_f = 5.0
s = a0 * np.sin(2 * np.pi * f0 * t)
ax1.plot(t, s, lw = 2, color = 'green')
ax1.xaxis.pan(-2)
ax1.grid()
fig.suptitle("""matplotlib.axis.Axis.pan()
function Example\n""", fontweight ="bold")
plt.show()
输出: