在Pyplot中无序绘制y轴

时间:2018-04-06 14:53:16

标签: python matplotlib weather-api

我有以下程序:

from weather import Weather
import matplotlib.pyplot as plt

weather = Weather()

highTemp = []
lowTemp = []

city = input('Enter the city for weather forecast \n: ')


location = weather.lookup_by_location(city)
condition = location.condition

print("The weather forecast for",city,"is",condition.text)

forecast = location.forecast
for forecast in forecast:
    forecasthigh = forecast.high  
    forecastlow = forecast.low
    print(forecast.date)      
    print("High temperature:",forecast.high)
    print("forecast.low",forecast.low)
    print(forecast.text)   

    highTemp.append(forecasthigh)
    lowTemp.append(forecastlow)
    #plt.axis([1,10,0,40])
    plt.plot(highTemp, '-r',lowTemp,'-b')
    plt.ylabel('Temperature')
    plt.xlabel('Days')
    plt.pause(0.05)
    print("----------------------------------------------")
plt.show

该程序使用Weather-API显示天气预报。我想绘制出现日的高温和低温变化。问题是Y标签乱序乱序导​​致图形遍布整个地方。

有没有办法更好地绘制图形或定义Y轴?

0 个答案:

没有答案