def test5(): # 绘画表格细节
# 构造数据
max_temperature = [26, 30, 31, 32, 33]
min_temperature = [12, 16, 16, 17, 18]
x = range(5)
plt.rcParams['font.family'] = ['SimHei']
x_ticks = ['星期{}'.format(i) for i in range(1, 6)]
plt.title('某年某周第N周的温度')
plt.xlabel('周')
plt.ylabel('温度:单位(℃)')
# 设置表格的标尺
plt.tick_params(top=False, right=False, left=False, bottom=False)
# 设置网络表格
plt.grid(alpha=0.2) # 透明度值 0-1之间
# 设置x轴标签
plt.xticks(x, x_ticks)
# 设置y轴标签
y = range(10, 35, 2)
plt.yticks(y)
fig, ax = plt.subplots()
# 取消边框
for key, spine in ax.spines.items():
# 'left', 'right', 'bottom', 'top'
if key == 'right' or key == 'top':
spine.set_visible(False)
# 设置RGB颜色
c1 =(70/255,130/255,180/255)
c2 =(0/255,255/255,0/255)
# 填充数据
plt.plot(x, max_temperature, label='最高温',linewidth=5,c=c2)
plt.plot(x, min_temperature, label='最低温',linewidth=5,c='m')
# 显示图例
plt.legend(loc=2)
# 绘画
plt.show()
if __name__ == '__main__':
test5()
老师,请问,取消边框这个视频中老师没有讲,但是给的资料代码中有,看不懂这串代码
