plt参数二
我还是曾经那个少年,
没有一丝丝改变,
天马行空的想象,
没有一丁点儿实现......
其源代码如下:
import matplotlib.pyplot as plt
import numpy as np
plt.rcParams['font.sans-serif'] = ['Microsoft YaHei']#显示中文
plt.figure(1)x = [x for x in range(1, 11)]
y1 = [y1+y1 for y1 in range(1, 11)]
y2 = [y2*y2 for y2 in range(1, 11)]
print(y1)
plt.plot(x, y1, color="r", )
plt.plot(x, y2)
plt.title("折线图")
plt.legend(["加法", "乘方"], loc='lower right')
plt.xlabel("x轴标题")
plt.ylabel("y轴标题")
plt.show()
(用了pycharm以后,可以直接复制粘贴过来了)
4、文本
import matplotlib.pyplot as plt
import numpy as np
plt.rcParams['font.sans-serif'] = ['Microsoft YaHei']#显示中文
plt.figure(1)
x = [x for x in range(1, 11)]
y1 = [y1+y1 for y1 in range(1, 11)]
y2 = [y2*y2 for y2 in range(1, 11)]
print(y1)
plt.plot(x, y1, color="r", )
plt.plot(x, y2)
plt.title("折线图")
plt.text(4, 60, r'这个点是(4,60)')
plt.plot(4, 60, '*', color='r')
plt.text(5, 70, r'这个点是(5,70)')
plt.plot(5, 70, '*', color='r')
plt.show()