某研究人员观测了一个星期的竹笋生长情况,记录了从第1天到第7天的竹笋长度如下表所示:
1 | 2 | 3 | 4 | 5 | 6 | 7 | |
长度(cm) | 13 | 20 | 29 | 35 | 48 | 59 | 65 |
请用Matplotlib绘制这7天的竹笋生长情况折线图.
代码如下:
import matplotlib.pyplot as plt
# data数据内容
x=[1,2,3,4,5,6,7]
y=[13,20,29,35,48,59,65]
plt.plot(x,y)# 设置x,y,标题
plt.title("一个星期的竹笋生长情况折线统计图")
plt.ylabel('长度/cm')
plt.xlabel('天数/天')# 用黑体显示中文
plt.rcParams['font.sans-serif'] = ['SimHei']plt.show()