pyplot 라이브러리 사용 중 원하는 결과를 얻지 못합니다.
조회수 1998회
import matplotlib.pyplot as plt import csv
def analyze(): day = range(1, 31) temp = [] datafile = '15_01.csv' with open(datafile, 'rt') as f: data = csv.reader(f, delimiter=',') for d in data: temp.append(d)
print(temp)
x = [day for day, temp, hum in temp]
y = [temp for day, temp, hum in temp]
p = plt.plot(x, y, 'r^--', label='temp')
plt.legend()
plt.title('2015 January tempature')
plt.xlabel('Day'), plt.ylabel('tempature')
plt.show()
if name == 'main': analyze()
코드는 위와 같고 csv파일을 읽어 1일~31일까지 기온 그래프를 그려주는데
위와 같이 순서대로 정렬되는 것이 아닌 1 -> 10 ~ 19 - >2 -> 20 ~ 29 와 같게 정렬됩니다. 제가 원하는 순서대로 정렬하려면 어떻게 해야할까요?
댓글 입력