假设我们有一个图形,其中包含三个针对三个不同参数的图形。但是对于所有三个图,我们具有相同的温度T = 4K。然后如何在图中添加此信息?
我对在标题中写它不感兴趣。我想要它本身的形象。
figtext效果很好。
figtextover text和的优点annotate是,figtext默认使用图形坐标,而其他默认使用轴的坐标(因此,如果不同图形之间的轴不同,则“ T = 4K”将四处移动)。
import matplotlib.pyplot as plt
plt.figure()
plt.xlim(-10, 10)
plt.ylim(0, .01)
plt.figtext(.8, .8, "T = 4K")
plt.show()
Run Code Online (Sandbox Code Playgroud)

这是使用的演示annotate。查看此示例以了解不同样式的注释。
import matplotlib.pyplot as plt
import numpy as np
plt.ion()
fig, ax = plt.subplots()
x = np.linspace(0,4,100)
plt.plot(x,2*x)
plt.plot(x,x**2)
plt.plot(x,np.sqrt(8*x))
ax.annotate('T = 4K', xy=(2,4), xycoords='data',
xytext=(-100,60), textcoords='offset points',
arrowprops=dict(arrowstyle='fancy',fc='0.6',
connectionstyle="angle3,angleA=0,angleB=-90"))
plt.show()
raw_input()
Run Code Online (Sandbox Code Playgroud)

| 归档时间: |
|
| 查看次数: |
8006 次 |
| 最近记录: |