一枚Python資料工程師為媽媽寫的幾行程式碼

TigerJin發表於2021-09-09
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()

圖片描述
祝天下的媽媽們,母親節快樂!(尤其我媽)

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/2144/viewspace-2798781/,如需轉載,請註明出處,否則將追究法律責任。

相關文章