光环境的测量与分析数据可视化

成果图:

 

程序实现:使用python语言,与用户交互获得数据,生成了eps文件,再在ps里处理后得到png格式的图。

有待改进:

将eps直接转化成jpg格式或png格式;

更好的用户交互模式;

有个small_block函数没有用上,可以表示最大值最小值的颜色;

现在只能绘7*9的图,兼容性不高。

import turtle as t
############变量定义###########

###########函数定义###########
def getname():
        global name
        name=input("请输入地图名称(自然光,人造光,自然光加人造光)\n")
def getnum():
        global num
        num=[]
        for i in range (7):                
                num.append ( list(map(int,input("输入第行数据 : ").strip().split(',')))[:9])
def find(list2):
        people_1=[]
        for i in range (7):
                people_1=people_1+list2[i]
        global min_1
        min_1=min(people_1)
        max_1=max(people_1)
        global deta
        deta=max_1-min_1
def big_block(color,num):
        t.pu()
        t.seth(0)
        t.pd()
        t.fillcolor(color)
        t.begin_fill()
        for i in range(4):
                t.fd(40)
                t.left(90)
        t.end_fill()
        t.write(num)
        t.pu()
        t.fd(40)
def small_block(color,number):
        t.pu()
        t.seth(0)
        t.pd()
        t.color(color)
        t.begin_fill()
        for i in range(4):
                t.fd(10)
                t.left(90)
        t.end_fill()
        t.pu()
        t.fd(20)
        t.write(number)
        
def mapmake(list2):
        n=0
        for i in range(len(list2)):
                for j in range(len(list2[0])):
                        n=list2[i][j]
                        a=round((n-min_1)/deta,2)
                        color=(a,1-a,0)
                        big_block(color,n)
                t.bk(360)
                t.left(-90)
                t.fd(40)

'''def sign(list1):
        t.goto(200,200)
        for i in range(len(list1)):
                a=round((n-min_1)/deta,2)
                t.pu()
                t.bk(20)
                t.left(-90)
                t.fd(20)
                t.pd()
                t.left(90)'''
                
def mapname(name):
        t.pu()
        t.goto(-50,-100)
        t.pd()
        t.write(name)
        t.pu()
                
###########主函数############
getname()
getnum()
find(num)
t.setup()
t.pu()
t.hideturtle()
t.tracer(False)
t.goto(-200,200)
t.pd()
find(num)
mapmake(num)
mapname(name)
ts = t.getscreen()
ts.getcanvas().postscript(file="work.eps")
t.done()
###sign(people[9])'''

 

 

 

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值