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()
将桌子位置和传感器位置,直观显示
最新推荐文章于 2021-05-26 12:24:21 发布