|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- import csv
- import matplotlib.pyplot as plt
- filename = 'sitka_weather_07-2018_simple.csv'
- with open(filename) as f:
- reader = csv.reader(f)
- header_row = next(reader)
- # 获取每个元素的索引和其值
- # for index, column_header in enumerate(header_row):
- # print(index, column_header)
- # 从文件中获取温度的最高温度
- highs = []
- for row in reader:
- high = int(row[5])
- highs.append(highs)
- plt.style.use('bmh')
- fig, ax = plt.subplots()
- ax.plot(highs, c='red')
- ax.set_title('最高温图图', fontsize=24)
- ax.set_xlabel('时间', fontsize=14)
- ax.set_ylabel('温度', fontsize=14)
- ax.tick_params(axes='both', which='major', labelsize=10)
- plt.rcParams['font.sans-serif'] = ['SimHei']
- plt.show()
复制代码
这个是把CSV文件中的数值提取出来并且用matplotlib绘制简单的图像的代码。
但是我运行的时候迟迟不出来图,但是也没有报错,是什么原因呢?
哪位前辈帮忙看一下啊?
把 plt.show() 放 with 外面试试看
|
|