分享

python中的figure什么意思

 昱雄藏书 2021-12-23

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

matplotlib.figure.Figure.text()方法

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

用法:text(self, x, y, s, fontdict=None, withdash=, **kwargs)

参数:此方法接受下面讨论的以下参数:

x:此参数是放置文本的x位置。

y:此参数是放置文本的y位置。

s:此参数是文本字符串。

fontdict:此参数是用于覆盖默认文本属性的字典。

withdash:此参数用于创建TextWithDash实例而不是Text实例。

返回值:此方法返回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()

输出:

f8545cf0f92216340560172b986b3a5b.png

范例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()

输出:

7f020a729cc2442c77c66684732c6d20.png

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约