美文网首页
为什么一定要掌握自学能力 笔记2

为什么一定要掌握自学能力 笔记2

作者: 秦生生 | 来源:发表于2019-03-10 18:13 被阅读0次

    为什么一定要掌握自学能力 笔记2

    人类发展指数

    hdi-china-1870-2015.txt文件和humandev.py 存放在 https://github.com/qinfeng8848/self-study

    python3环境安装 https://www.liaoxuefeng.com/wiki/0014316089557264a6b348958f449949df42a6d3a2e542c000/0014316090478912dab2a3a9e8f4ed49d28854b292f85bb000

    matplotlib 安装 https://morvanzhou.github.io/tutorials/data-manipulation/plt/1-2-install/

    以下是我把代码跑起来的记录

    将代码保存在self-study文件夹取名humandev.py

    import matplotlib.pyplot as plt
    import numpy as np
    plt.figure(figsize=(10,5))
    
    lebdata = np.genfromtxt('life-expectancy-china-1960-2016.txt',
                         delimiter=',',
                         names=['x', 'y'])
    
    hdidata = np.genfromtxt('hdi-china-1870-2015.txt',
                         delimiter=',',
                         names=['x', 'y'])
    
    plt.plot(hdidata['x'], hdidata['y'])
    plt.tick_params(axis='x', rotation=70)
    plt.title('China: 1870 - 2015')
    plt.savefig('human-development-index.png', transparent=True)plt.legend(['Human Development Index'])
    plt.plot(lebdata['x'], lebdata['y']*0.005)
    plt.plot(secondary_y=True)
    plt.savefig('human-development-index-china-1870-2015.png', transparent=True)
    plt.show()
    # data from:# https://ourworldindata.org/957e133e-f3e9-4bf2-9627-dbf30ebc9b4d
    
    

    https://ourworldindata.org/957e133e-f3e9-4bf2-9627-dbf30ebc9b4d 下载 hdi-china-1870-2015.txt 结果出错,查找不到数据

    image

    https://ourworldindata.org 查找 development

    image

    下载人类发展指数

    image

    将中国部分导出并保存成 hdi-china-1870-2015.txt

    image

    在终端中运行python3 humandev.py,正常没有报错信息,

    image

    取消代码中注释的输出

    image

    在终端中运行python3 humandev.py ,报错,最后一行

    image

    完成修改

    image

    在终端中运行python3 humandev.py 显示正常图片

    image

    相关文章

      网友评论

          本文标题:为什么一定要掌握自学能力 笔记2

          本文链接:https://www.haomeiwen.com/subject/gglppqtx.html