My plot doesn't show line but only dot in graph

22 Views Asked by At

I would like to get weather data and visualize it as graph. but my plotting shows only dot. Could you please help me to make it show line for me?

import requests
import json
import matplotlib.pyplot as plt

city = "osan" #도시
apiKey = "#####################################"
lang = 'en' #언어
units = 'metric' #화씨 온도를 섭씨 온도로 변경
api = f"https://api.openweathermap.org/data/2.5/forecast?q={city}&appid={apiKey}&lang={lang}&units={units}"
result = requests.get(api)
result = json.loads(result.text)

name = result['city']['name']


print('City: ' + name)

for i in range(0, 39):
    
    date = result['list'][i]['dt_txt']
    temp = result['list'][i]['main']['temp']
    print('Time: ' + date)
    print('Temp: ' + str(temp))
    plt.plot(date, temp, 'go-', label='line', linewidth=2)

plt.show()
0

There are 0 best solutions below