Add drawpipe.py

This commit is contained in:
DingZQ
2025-04-26 23:14:41 +08:00
parent 86e06e1717
commit 01be4ce1c4
2 changed files with 23 additions and 1 deletions

23
drawpipe.py Normal file
View File

@@ -0,0 +1,23 @@
import json
import matplotlib.pyplot as plt
def draw_pipe():
# 读取json文件
with open(r'C:\Users\dingsu\Desktop\links_coordinates.json', 'r') as f:
pipe_data = json.load(f)
# 创建一个空列表来存储所有点的坐标
# 将两个点连接成一条线,然后每条线都绘制出来
for item in pipe_data:
x1 = item[0][0]
y1 = item[0][1]
x2 = item[1][0]
y2 = item[1][1]
plt.plot([x1, x2], [y1, y2], 'r-')
plt.show()
if __name__ == "__main__":
draw_pipe()