Files
TJWaterServer/drawpipe.py
2025-04-26 23:14:41 +08:00

24 lines
558 B
Python

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()