python中的figure什么意思_Python Matplotlib.figure.Figure.text()用法及代码示例

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
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值