📌  相关文章
📜  Python中的 Matplotlib.figure.Figure.text()

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

Python中的 Matplotlib.figure.Figure.text()

Matplotlib是Python中的一个库,它是 NumPy 库的数值数学扩展。 figure 模块提供了顶级 Artist,即 Figure,其中包含所有绘图元素。该模块用于控制所有绘图元素的子图和顶级容器的默认间距。

matplotlib.figure.Figure.text() 方法

matplotlib 库的text() 方法图模块用于将文本添加到图。

下面的示例说明了 matplotlib.figure 中的 matplotlib.figure.Figure.text()函数:

示例 1:

#Implementation of matplotlib function
import matplotlib.pyplot as plt
    
      
fig, ax = plt.subplots()
   
fig.text(0.28, 0.5, 
         'GeeksforGeeks', 
         style = 'italic',
         fontsize = 30,
         color = "green")
   
ax.set(xlim = (0, 8),
       ylim = (0, 8))
   
fig.suptitle("""matplotlib.figure.Figure.text()
function Example\n\n""",fontweight="bold")
  
fig.show()

输出:

示例 2:

# Implementation of matplotlib function
import matplotlib.pyplot as plt
   
fig, ax = plt.subplots()
ax.set_xlabel('xlabel')
ax.set_ylabel('ylabel')
   
fig.text(0.3, 0.7,
         'GeeksforGeeks',
         style = 'italic',
         fontsize = 30,
         bbox ={'facecolor':'green',
                'alpha':0.6,
                'pad':10})
   
fig.text(0.35, 0.6, 
         'Python matplotlib Module',
         fontsize = 15)
   
fig.text(0.35, 0.3,
         'Figure Class - Text Function')
   
fig.text(0, 0, 'by-Shubham Singh',
        verticalalignment ='bottom', 
        horizontalalignment ='left',
        transform = ax.transAxes,
        color ='green',
        fontsize = 5)
   
   
   
ax.set(xlim =(0, 10), ylim =(0, 10))
  
fig.suptitle("""matplotlib.figure.Figure.text()
function Example\n\n""", fontweight ="bold")
  
fig.show()

输出: