📌  相关文章
📜  Python中的 Matplotlib.axis.Tick.findobj()函数

📅  最后修改于: 2022-05-13 01:55:15.655000             🧑  作者: Mango

Python中的 Matplotlib.axis.Tick.findobj()函数

Matplotlib是Python中的一个库,它是 NumPy 库的数值数学扩展。它是Python中用于二维数组图的惊人可视化库,用于处理更广泛的 SciPy 堆栈。

Matplotlib.axis.Tick.findobj()函数

matplotlib 库的轴模块中的Tick.findobj()函数用于查找艺术家对象。

下面的示例说明了 matplotlib.axis 中的 matplotlib.axis.Tick.findobj()函数:

示例 1:

Python3
# Implementation of matplotlib function
from matplotlib.axis import Tick
import matplotlib.pyplot as plt  
from matplotlib.lines import Line2D  
import numpy as np  
from numpy.random import rand  
        
       
fig, ax2 = plt.subplots()  
        
ax2.bar(range(10), rand(10), picker = True)  
     
print("Value return : \n",  
      *list(Tick.findobj(ax2)), sep ="\n")
   
fig.suptitle("""matplotlib.axis.Tick.findobj()
function Example\n""", fontweight ="bold")  
     
plt.show()


Python3
# Implementation of matplotlib function
from matplotlib.axis import Tick
import numpy as np  
import matplotlib.pyplot as plt  
import matplotlib.patches as mpatches  
       
fig, ax = plt.subplots()  
x, y = 10 * np.random.rand(2, 1000)  
ax.plot(x, y, 'go', alpha = 0.2)  
       
circ = mpatches.Circle((0.5, 0.5), 0.25,  
                       transform = ax.transAxes,  
                       facecolor ='blue',   
                       alpha = 0.75)  
ax.add_patch(circ)    
     
print("Value return : \n",  
      *list(Tick.findobj(ax)), sep ="\n")
   
fig.suptitle("""matplotlib.axis.Tick.findobj()
function Example\n""", fontweight ="bold")  
     
plt.show()


输出:

Value return : 

Rectangle(xy=(-0.4, 0), width=0.8, height=0.787316, angle=0)
Rectangle(xy=(0.6, 0), width=0.8, height=0.901399, angle=0)
Rectangle(xy=(1.6, 0), width=0.8, height=0.783699, angle=0)
Rectangle(xy=(2.6, 0), width=0.8, height=0.516764, angle=0)
Rectangle(xy=(3.6, 0), width=0.8, height=0.284635, angle=0)
Rectangle(xy=(4.6, 0), width=0.8, height=0.228809, angle=0)
Rectangle(xy=(5.6, 0), width=0.8, height=0.347976, angle=0)
Rectangle(xy=(6.6, 0), width=0.8, height=0.311647, angle=0)
Rectangle(xy=(7.6, 0), width=0.8, height=0.0261189, angle=0)
Rectangle(xy=(8.6, 0), width=0.8, height=0.921416, angle=0)
Spine
Spine
Spine
Spine
Text(0.5, 0, '')
Text(1, 0, '')
Line2D()
Line2D()
Line2D((0,0),(0,1))
Text(0, 0, '')
Text(0, 1, '')

Line2D()
Line2D()
Line2D((0,0),(0,1))
Text(0, 0, '')
Text(0, 1, '')

Line2D()
Line2D()
Line2D((0,0),(0,1))
Text(0, 0, '')
Text(0, 1, '')

Line2D()
Line2D()
Line2D((0,0),(0,1))
Text(0, 0, '')
Text(0, 1, '')

Line2D()
Line2D()
Line2D((0,0),(0,1))
Text(0, 0, '')
Text(0, 1, '')

Line2D()
Line2D()
Line2D((0,0),(0,1))
Text(0, 0, '')
Text(0, 1, '')

Line2D()
Line2D()
Line2D((0,0),(0,1))
Text(0, 0, '')
Text(0, 1, '')

XAxis(80.0,52.8)
Text(0, 0.5, '')
Text(0, 0.5, '')
Line2D()
Line2D()
Line2D((0,0),(1,0))
Text(0, 0, '')
Text(1, 0, '')

Line2D()
Line2D()
Line2D((0,0),(1,0))
Text(0, 0, '')
Text(1, 0, '')

Line2D()
Line2D()
Line2D((0,0),(1,0))
Text(0, 0, '')
Text(1, 0, '')

Line2D()
Line2D()
Line2D((0,0),(1,0))
Text(0, 0, '')
Text(1, 0, '')

Line2D()
Line2D()
Line2D((0,0),(1,0))
Text(0, 0, '')
Text(1, 0, '')

Line2D()
Line2D()
Line2D((0,0),(1,0))
Text(0, 0, '')
Text(1, 0, '')

YAxis(80.0,52.8)
Text(0.5, 1.0, '')
Text(0.0, 1.0, '')
Text(1.0, 1.0, '')
Rectangle(xy=(0, 0), width=1, height=1, angle=0)
AxesSubplot(0.125,0.11;0.775x0.77)

示例 2:

Python3

# Implementation of matplotlib function
from matplotlib.axis import Tick
import numpy as np  
import matplotlib.pyplot as plt  
import matplotlib.patches as mpatches  
       
fig, ax = plt.subplots()  
x, y = 10 * np.random.rand(2, 1000)  
ax.plot(x, y, 'go', alpha = 0.2)  
       
circ = mpatches.Circle((0.5, 0.5), 0.25,  
                       transform = ax.transAxes,  
                       facecolor ='blue',   
                       alpha = 0.75)  
ax.add_patch(circ)    
     
print("Value return : \n",  
      *list(Tick.findobj(ax)), sep ="\n")
   
fig.suptitle("""matplotlib.axis.Tick.findobj()
function Example\n""", fontweight ="bold")  
     
plt.show()

输出:

Value return : 

Circle(xy=(0.5, 0.5), radius=0.25)
Line2D(_line0)
Spine
Spine
Spine
Spine
Text(0.5, 0, '')
Text(1, 0, '')
Line2D()
Line2D()
Line2D((0,0),(0,1))
Text(0, 0, '')
Text(0, 1, '')

Line2D()
Line2D()
Line2D((0,0),(0,1))
Text(0, 0, '')
Text(0, 1, '')

Line2D()
Line2D()
Line2D((0,0),(0,1))
Text(0, 0, '')
Text(0, 1, '')

Line2D()
Line2D()
Line2D((0,0),(0,1))
Text(0, 0, '')
Text(0, 1, '')

Line2D()
Line2D()
Line2D((0,0),(0,1))
Text(0, 0, '')
Text(0, 1, '')

Line2D()
Line2D()
Line2D((0,0),(0,1))
Text(0, 0, '')
Text(0, 1, '')

Line2D()
Line2D()
Line2D((0,0),(0,1))
Text(0, 0, '')
Text(0, 1, '')

Line2D()
Line2D()
Line2D((0,0),(0,1))
Text(0, 0, '')
Text(0, 1, '')

XAxis(80.0,52.8)
Text(0, 0.5, '')
Text(0, 0.5, '')
Line2D()
Line2D()
Line2D((0,0),(1,0))
Text(0, 0, '')
Text(1, 0, '')

Line2D()
Line2D()
Line2D((0,0),(1,0))
Text(0, 0, '')
Text(1, 0, '')

Line2D()
Line2D()
Line2D((0,0),(1,0))
Text(0, 0, '')
Text(1, 0, '')

Line2D()
Line2D()
Line2D((0,0),(1,0))
Text(0, 0, '')
Text(1, 0, '')

Line2D()
Line2D()
Line2D((0,0),(1,0))
Text(0, 0, '')
Text(1, 0, '')

Line2D()
Line2D()
Line2D((0,0),(1,0))
Text(0, 0, '')
Text(1, 0, '')

Line2D()
Line2D()
Line2D((0,0),(1,0))
Text(0, 0, '')
Text(1, 0, '')

Line2D()
Line2D()
Line2D((0,0),(1,0))
Text(0, 0, '')
Text(1, 0, '')

YAxis(80.0,52.8)
Text(0.5, 1.0, '')
Text(0.0, 1.0, '')
Text(1.0, 1.0, '')
Rectangle(xy=(0, 0), width=1, height=1, angle=0)
AxesSubplot(0.125,0.11;0.775x0.77)