Matplotlib.axis.axis.get_minorticklabels() - 获取次要标记的文本实例列表

Matplotlib.axis.axis.get_minorticklabels()

matplotlib库的Axis模块中的Axis.get_minorticklabels()函数用于获取次要标记的文本实例列表。

语法:Axis.get_minorticklabels(self)

参数:该方法不接受任何参数。

返回值:该方法返回小标记的Text实例列表。

下面的例子演示了matplotlib.axis.axis.get_minorticklabels()函数在matplotlib.axis中的作用:

示例1

# Implementation of matplotlib function 
import numpy as np
from matplotlib.axis import Axis  
import matplotlib.pyplot as plt
import matplotlib.ticker as ticker
      
np.random.seed(19680801)
   
fig, ax = plt.subplots()
ax.plot(100*np.random.rand(20))
   
Axis.set_minor_locator(ax.xaxis, ticker.MultipleLocator(1)) 
   
print("Value of get_minorticklabels() :")
for i in ax.xaxis.get_minorticklabels():
    print(i)
       
plt.title("Matplotlib.axis.Axis.get_minorticklabels()\n\
Function Example", fontsize = 12, fontweight ='bold') 
  
plt.show()

输出:

Matplotlib.axis.axis.get_minorticklabels()

Value of get_minorticklabels() :
Text(0, 0, '')
Text(0, 0, '')
Text(0, 0, '')
Text(0, 0, '')
Text(0, 0, '')
Text(0, 0, '')
Text(0, 0, '')
Text(0, 0, '')
Text(0, 0, '')
Text(0, 0, '')
Text(0, 0, '')
Text(0, 0, '')
Text(0, 0, '')
Text(0, 0, '')
Text(0, 0, '')
Text(0, 0, '')
Text(0, 0, '')

示例2

# Implementation of matplotlib function 
import numpy as np
from matplotlib.axis import Axis  
import matplotlib.pyplot as plt
import matplotlib.ticker as ticker
   
fig, ax = plt.subplots()
ax.plot(np.random.rand(1000),'go')
   
Axis.set_minor_locator(ax.yaxis, ticker.MultipleLocator(1))
  
print("Value of get_minorticklabels() :")
for i in ax.yaxis.get_minorticklabels():
    print(i)
       
plt.title("Matplotlib.axis.Axis.get_minorticklabels()\n\
Function Example", fontsize = 12, fontweight ='bold') 
  
plt.show()

输出:

Matplotlib.axis.axis.get_minorticklabels()

Value of get_minorticklabels() :
Text(0, 0, '')
Text(0, 0, '')

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程