x,y:浮点数。放置文本的位置。默认情况下,这是在数据坐标中。可以使用变换参数来更改坐标系 。
s:str。文本内容。
fontdict:dict, 默认: None。用于覆盖默认文本属性的字典。如果fontdict为None,则默认值由确定rcParams(链接: https://matplotlib.org/api/matplotlib_configuration_api.html#matplotlib.rcParams.)
** kwargs:文本的属性。 其他参数,如,fontfamily or family(字体)、fontsize or size(字体大小)、fontstyle or style(字体风格)、color or c、label等
in:
import numpy as np #导入 numpyas import matplotlib.pyplot as plt #导入 matplotlib.pyplot x=np.arange(1,10,1) y1=x*x y2=np.log(x) fig=plt.figure() ax=fig.add_subplot(111) ax.plot(x,y1,'y') ax.text(4,4,'funtion:y=x^2',size=15)链接: https://matplotlib.org/gallery/pyplots/pyplot_mathtext.html#sphx-glr-gallery-pyplots-pyplot-mathtext-py
in:
fig=plt.figure() ax=fig.add_subplot(111) ax.set_xlim([1,7]) ax.set_ylim([1,5]) ax.text(2,4,r'$s(t) = \mathcal{A}\sin(2 \omega t)$',size=25) ax.text(3,3,r"$\alpha \beta \epsilon$",size=25)out:
