在这个数据中(130,130),(520,520),(1020,1020)为固定的点,根据这三个点的距离进行绘制
时间: 2024-06-08 08:08:39 浏览: 89
可以使用Python的matplotlib库进行绘制。代码如下:
```python
import matplotlib.pyplot as plt
# 三个固定点的坐标
point1 = (130, 130)
point2 = (520, 520)
point3 = (1020, 1020)
# 计算三个点两两之间的距离
dist12 = ((point1[0]-point2[0])**2 + (point1[1]-point2[1])**2)**0.5
dist13 = ((point1[0]-point3[0])**2 + (point1[1]-point3[1])**2)**0.5
dist23 = ((point2[0]-point3[0])**2 + (point2[1]-point3[1])**2)**0.5
# 绘制三个点和它们之间的连线
plt.plot([point1[0], point2[0]], [point1[1], point2[1]], 'b-')
plt.plot([point1[0], point3[0]], [point1[1], point3[1]], 'b-')
plt.plot([point2[0], point3[0]], [point2[1], point3[1]], 'b-')
plt.plot(point1[0], point1[1], 'ro')
plt.plot(point2[0], point2[1], 'ro')
plt.plot(point3[0], point3[1], 'ro')
# 添加距离文本
plt.text((point1[0]+point2[0])/2, (point1[1]+point2[1])/2, str(round(dist12)), fontsize=8, color='r')
plt.text((point1[0]+point3[0])/2, (point1[1]+point3[1])/2, str(round(dist13)), fontsize=8, color='r')
plt.text((point2[0]+point3[0])/2, (point2[1]+point3[1])/2, str(round(dist23)), fontsize=8, color='r')
plt.show()
```
结果如下图所示:
![image](https://user-images.githubusercontent.com/38697734/128468026-6dbb4c6f-dc41-4d1c-9a83-ea2f1d9ffca6.png)
阅读全文