将桌子位置和传感器位置,直观显示

import matplotlib.pyplot as plt
import json

desk_type = ['x', 'C', 'C', 'C', 'C', 'C', 'C', 'B', 'A', 'A', 'B', 'B', 'B', 'B', 'E', 'E', 'B', 'B', 'B', 'D', 'A', 'A',
             'A', 'A', 'A', 'A', 'A']

desk_type_size = dict(A=[0.91, 0.91], B=0.5, C=[0.91, 0.91 * 2], D=0.75, E=[2.5, 1.1])
filter_data = 'filter_data.json'
filter_data_3point = 'filter_data_3point.json'

fig = plt.figure()

point3 = json.load(open(filter_data_3point))
print(point3)

for i in range(1, 7):
    print(point3[0][str(i)])
    plt.plot([point3[0][str(i)][0], point3[1][str(i)][0]], [point3[0][str(i)][1], point3[1][str(i)][1]])
    plt.plot([point3[0][str(i)][0], point3[2][str(i)][0]], [point3[0][str(i)][1], point3[2][str(i)][1]])
    plt.text(point3[0][str(i)][0] + 0.5, point3[0][str(i)][1], i, fontsize=12)
a = json.load(open(filter_data))
print(a[0]['7'])

plt.xlim(-10, 10)

plt.ylim(-22, 0)

for i in range(7, 27):
    print(i)
    if (desk_type[i] == 'A') or (desk_type[i] == 'E'):

        rect = plt.Rectangle(
            [a[0][str(i)][0] - desk_type_size[desk_type[i]][0] / 2, a[0][str(i)][1] - desk_type_size[desk_type[i]][1] / 2],
            desk_type_size[desk_type[i]][0], desk_type_size[desk_type[i]][1], color='deepskyblue')
        plt.text(a[0][str(i)][0] + 0.5, a[0][str(i)][1], i, fontsize=12)
        plt.gca().add_patch(rect)

    elif desk_type[i] == 'B':
        cir1 = plt.Circle(xy=(a[0][str(i)][0], a[0][str(i)][1]), radius=desk_type_size['B'], color='deepskyblue')
        plt.text(a[0][str(i)][0] + 0.5, a[0][str(i)][1], i, fontsize=12)
        plt.gca().add_patch(cir1)

    elif desk_type[i] == 'D':
        cir1 = plt.Circle(xy=(a[0][str(i)][0], a[0][str(i)][1]), radius=desk_type_size['D'], color='deepskyblue')
        plt.text(a[0][str(i)][0] + 0.5, a[0][str(i)][1], i, fontsize=12)
        plt.gca().add_patch(cir1)


# 红外阵列
IR_sensor = 'IR_sensor.json'
IR_sensor_position = json.load(open(IR_sensor))
for i in range(3, 22):
    cir1 = plt.Circle(xy=(IR_sensor_position[0][str(i)][0], IR_sensor_position[0][str(i)][1]), radius=0.1, color='r')
    plt.text(IR_sensor_position[0][str(i)][0] + 0.5, IR_sensor_position[0][str(i)][1], i, fontsize=12, color = 'r')
    plt.gca().add_patch(cir1)

plt.show()

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值