随手一画的方块图

import  matplotlib.pyplot  as plt
import random
import numpy as np
import pandas as pd
def MaxMinNormalization(x,Max,Min):
    x = (x - Min) / (Max - Min);
    return x/3.00124732715609
def graphpic(w,h,p,q,list66,listgg):
    sx = 0
    num = 2
    sy = 0.2 + 4* (h + q)
    sum = 0
    for i, kkk in zip(list66, listgg):
        if i == 0:
            rect3 = plt.Rectangle((sx, sy), kkk + sum, h + q, color='red')
            ax.add_patch(rect3)
        elif i == 3:
            rect3 = plt.Rectangle((sx, sy), kkk + sum, h + q, color='blue')
            ax.add_patch(rect3)
        else:
            rect3 = plt.Rectangle((sx, sy), kkk + sum, h + q, color='green')
            ax.add_patch(rect3)
        sum += kkk
        sx += kkk
        #q=2*q
def graphpic2(w,h,p,q,list66,listgg):
    sx = 0
    num = 2
    sy = 0.2 + 3 * (h + q)
    sum = 0
    for i, kkk in zip(list66, listgg):
        if i == 0:
            rect3 = plt.Rectangle((sx, sy), kkk + sum, h + q, color='red')
            ax.add_patch(rect3)
        elif i == 3:
            rect3 = plt.Rectangle((sx, sy), kkk + sum, h + q, color='blue')
            ax.add_patch(rect3)
        else:
            rect3 = plt.Rectangle((sx, sy), kkk + sum, h + q, color='green')
            ax.add_patch(rect3)
        sum += kkk
        sx += kkk
        #p=2*p
        #q=2*q
def graphpic3(w,h,p,q,list66,listgg):
    sx=0
    num=2
    sy=0.2+2*(h+q)
    sum=0
    for i,kkk in zip(list66,listgg):
        if i==0:
            rect3 = plt.Rectangle((sx, sy), kkk+sum, h+q, color='red')
            ax.add_patch(rect3)
        elif i==3:
            rect3=plt.Rectangle((sx, sy), kkk+sum, h+q, color='blue')
            ax.add_patch(rect3)
        else:
            rect3 = plt.Rectangle((sx, sy), kkk+sum, h + q, color='green')
            ax.add_patch(rect3)
        sum += kkk
        sx += kkk
        #p=2*p
        #q=2*q
def graphpic4(w,h,p,q,list66,listgg):
    sx=0
    num=3
    sy=0.2+h+q
    sum = 0
    for i,kkk in zip(list66,listgg):
        if i==0:
            rect3 = plt.Rectangle((sx, sy), kkk+sum, h+q, color='red')
            ax.add_patch(rect3)
        elif i==3:
            rect3=plt.Rectangle((sx, sy), kkk+sum, h+q, color='blue')
            ax.add_patch(rect3)
        else:
            rect3 = plt.Rectangle((sx, sy),kkk+sum, h + q, color='green')
            ax.add_patch(rect3)
        sum += kkk
        sx += kkk
        #p=2*p
        #q=2*q
def graphpic5(w,h,p,q,list66,listgg):
    sx=0
    num=4
    sy=0.2
    sum=0
    for i,kkk in zip(list66,listgg):
        if i==0:
            rect3 = plt.Rectangle((sx, sy), (kkk+sum), h+q, color='red')
            ax.add_patch(rect3)
        elif i==3:
            rect3=plt.Rectangle((sx, sy), (kkk+sum), h+q, color='blue')
            ax.add_patch(rect3)
        else:
            rect3 = plt.Rectangle((sx, sy), (kkk+sum), h + q, color='green')
            ax.add_patch(rect3)
        sum+=kkk
        sx+=kkk
        #p=2*p
        #q=2*q

def Randomlist(t,no):
    randomlist=[]
    for qq in range(no):
        randomlist.append(t)
    return randomlist
def getDu(zeze):
    listzeze=[]
    for boy in zeze:
        listzeze.append(boy)
    return listzeze
def pdread(getdd):
    nba=[]
    for getpp in  getdd:
        nba.append(getpp)
    return nba
if __name__ == '__main__':
    list = []
    wr = pd.read_excel("预处理数据.xlsx")
    ws = wr.num
    length = []
    for kk in ws:
        length.append(kk)
    for i in length:
        t = MaxMinNormalization(i, max(length), min(length))
        list.append(t)

    fig = plt.figure()
    ax = fig.add_subplot(111)   #创建子图

    # list=[0,2,3,0,2]
    # list2=[3,3,0,2,0]
    # list3=[2,3,0,0,2]
    # list4=[0,0,2,3,0]
    # list5=[3,3,2,2,3]
    # list=Randomlist(0,243)
    # list2=Randomlist(2,243)
    # list3=Randomlist(3,243)
    list1=pdread(wr.角度1)
    list2=pdread(wr.角度2)
    list3=pdread(wr.角度3)
    list4=pdread(wr.角度4)
    list5=pdread(wr.角度5)
    graphpic(0,0,0.002,0.1,list1,list)
    graphpic2(0,0,0.002,0.1,list2,list)
    graphpic3(0,0,0.002,0.1,list3,list)
    graphpic4(0, 0, 0.002, 0.1, list4,list)
    #list55=[2,2,3,0,3]
    #listss=[0.1, 0.2, 0.6, 0.05, 0.05]
    graphpic5(0, 0, 0.002, 0.1, list5,list)
    labletext=['create','novel','ecxp','relate work','writing']
    for label in range(5):
        plt.text(-0.08,0.25+0.1*label,labletext[label])
    # graphpic4(0,0,0.1,0.1,list4)
    # graphpic5(0,0,0.1,0.1,list5)
    # rect = plt.Rectangle((0.1,0.2),0.4,0.3, color="red")# (0.1,0.2)为左下角的坐标,0.4,0.3为宽和高,负数为反方向,红色填充
    # rect2=plt.Rectangle((0.1+0.4,0.2),0.4,0.3, color="green")
    #
    # ax.add_patch(rect)
    # ax.add_patch(rect2)
    plt.axis('off')
    plt.show()

结果图如下:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值