标题
在科技论文中,图片的标题是不需要的。标题一般另起一行,标上标号,写在图片的下面。但是,有些时候我们需要给图片添加标题,这时候就需要用到title()函数了。
代码展示
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0, 10, 100)
abs = np.random.randn(100)
y1 = 2 * x + 9 + abs
y2 = 2 * x + 9
plt.scatter(x, y1, c="red", label="scatter")
plt.plot(x, y2, ls="-", lw=1, label="line")
plt.legend()
plt.xlabel("x")
plt.ylabel("y")
plt.title("the first picture")
plt.show()
重要代码解释
plt.title(string)
- string:标题。