欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

4、比较纽约市的月平均气温

程序员文章站 2022-07-14 13:29:32
...
import matplotlib.pyplot as plt


def create_graph():
    nyc_temp_2000 = [31.3, 37.3, 47.2, 51.0, 63.5, 71.3, 72.3, 72.7, 66.0, 57.0, 45.3, 31.1]
    nyc_temp_2006 = [40.9, 35.7, 43.1, 55.7, 63.1, 71.0, 77.9, 75.8, 66.6, 56.2, 51.9, 43.6]
    nyc_temp_2012 = [37.3, 40.9, 50.9, 54.8, 65.1, 71.0, 78.8, 76.7, 68.8, 58.0, 43.9, 41.5]
    months = range(1, 13)

    plt.plot(months, nyc_temp_2000, months, nyc_temp_2006, months, nyc_temp_2012, marker='o')

    plt.legend([2000, 2006, 2012])

    plt.title('Average monthly temperature in NYC')
    plt.xlabel('Month')
    plt.ylabel('Temperature')

    plt.savefig('late.png')
    plt.show()


if __name__ == '__main__':
    create_graph()

4、比较纽约市的月平均气温

相关标签: python 数学编程