继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

一枚Python数据工程师为妈妈写的几行代码

途索
关注TA
已关注
手记 3
粉丝 757
获赞 123
if __name__=="__main__":
    import seaborn as sns
    import numpy as np
    from pylab import *
    #Define Data
    data=np.zeros([64,64],dtype="float")

    #Begin to Draw
    POS_VALUE=0.8
    NEG_VALUE=-0.8
    data[1:31,1]=POS_VALUE
    for i in range(1,11):
        data[i,i]=POS_VALUE
    for i in range(11,21):
        data[21-i,i]=POS_VALUE
    data[1:31,21]=POS_VALUE

    data[2,31:34]=POS_VALUE
    for i in range(0,7):
        data[i+2,31-i]=POS_VALUE
    data[8:25,25]=POS_VALUE
    for i in range(25,32):
        data[i,i]=POS_VALUE
    data[31,31:34]=POS_VALUE
    for i in range(34,41):
        data[65-i,i]=POS_VALUE
    data[8:25,40]=POS_VALUE
    for i in range(0,7):
        data[i+2,i+34]=POS_VALUE

    data[1:31,43]=POS_VALUE
    for i in range(1,11):
        data[i,43+i]=POS_VALUE
    for i in range(11,21):
        data[21-i,43+i]=POS_VALUE
    data[1:31,63]=POS_VALUE

    for i in range(37,44):
        data[i,i-11]=NEG_VALUE
    for i in range(37,44):
        data[i,64-i]=NEG_VALUE
    for i in range(44,57):
        data[i,i-23]=NEG_VALUE
    for i in range(44,57):
        data[i,89-i]=NEG_VALUE
    for i in range(37,44):
        data[i,i+2]=NEG_VALUE
    for i in range(37,45):
        data[i,77-i]=NEG_VALUE

    data[33:63,11]=NEG_VALUE
    data[33,9:14]=NEG_VALUE
    data[63,9:14]=NEG_VALUE

    data[33:57,47]=NEG_VALUE
    for i in range(57,64):
        data[i,i-10]=NEG_VALUE
    data[63,53:56]=NEG_VALUE
    for i in range(0,6):
        data[63-i,i+55]=NEG_VALUE
    data[33:58,61]=NEG_VALUE

    #SHOW THE MAP
    sns.heatmap(-data,xticklabels=False,yticklabels=False)
    show()

^.^
祝天下的妈妈们,母亲节快乐!(尤其我妈)

打开App,阅读手记
23人推荐
发表评论
随时随地看视频慕课网APP

热门评论

厉害了,太厉害了啊,

所有代码都放在if __main__ 里面,这个代码习惯可不好

看到的话请加一下我  谢谢老师

查看全部评论