【人工智能数据分析day05】matplotlib小案例+如果列表a表示10点到12点的每一分钟的气温,如何绘制折线图观察每分钟气温的变化情况?

在这里插入图片描述
在这里插入图片描述

import matplotlib.pyplot as plt
import random

fig = plt.figure(figsize=(20,8),dpi=80)

x = range(120)
a = [random.randint(20,35) for i in range(120)]
y = a

random.seed(10)

plt.plot(x,y)

_x_ticks = ["10点{}分".format(i) for i in x if i<60]
_x_ticks += ["11点{}分".format(i-60) for i in x if i>=60]
plt.xticks(x[::5],_x_ticks[::5],rotation=90)
plt.show()

在这里插入图片描述
在这里插入图片描述
坐标轴变成中文的见下期分析

发布了199 篇原创文章 · 获赞 81 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/qq_35456045/article/details/104090317