Matplotlib.axes.axes.get_navigate_mode()
Matplotlib是Python中的一个库,它是NumPy库的数值-数学扩展。Axes包含了大多数图形元素:Axis、Tick、Line2D、Text、Polygon等,并设置坐标系。Axes的实例通过callbacks属性支持回调。
函数:Matplotlib.axes.axes.get_navigate_mode()
matplotlib库的Axes模块中的Axes.get_navigate_mode()函数用于获取导航工具栏按钮的状态:’ PAN ‘, ‘ ZOOM ‘或None。
语法:Axes.get_navigate_mode(self)
参数:该方法不接受任何参数。
返回值:该方法返回导航模式。
下面的例子演示了matplotlib.axes.axes.get_navigate_mode()函数在matplotlib.axes中的作用:
示例1
# Implementation of matplotlib function
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
    
t = np.arange(0.0, 2, 0.001)
s = 1 + np.sin(8 * np.pi * t)*0.4
    
fig, ax = plt.subplots()
ax.plot(t, s)
  
w = ax.get_navigate_mode()
  
ax.text(0.5, 1.43, "Navigate Mode : " + str(w), 
        fontweight ="bold")
  
ax.set(xlabel ='X-Axis', ylabel ='Y-Axis',
       xlim =(0, 1.5), ylim =(0.5, 1.5))
  
ax.set_title('matplotlib.axes.Axes.get_navigate_mode()\
 function Example', fontweight ="bold")
  
ax.grid()
plt.show()
输出:

示例2
# Implementation of matplotlib function
import numpy as np
import matplotlib.pyplot as plt
np.random.seed(19680801)
   
fig, ax = plt.subplots()
   
x, y, s, c = np.random.rand(4, 200)
s *= 200
   
ax.scatter(x, y, s, c)
ax.set_navigate_mode("ZOOM")
w = ax.get_navigate_mode()
  
ax.text(0.3, .65, "Navigate Mode : " + str(w), 
        fontweight ="bold")
  
ax.set_title('matplotlib.axes.Axes.get_navigate_mode()\
 function Example', fontweight ="bold")
  
ax.grid()
plt.show()
输出:

极客教程