以下是一个使用 matplotlib 库的示例代码,可以画出三辆车的配送路线图:

import matplotlib.pyplot as plt

# 坐标点
points = [[35, 35], [41, 49], [35, 17], [55, 45], [55, 20], [15, 30], [25, 30], [20, 50], [10, 43], [55, 60], [30, 60]]

# 路线
routes = [[0, 4, 2, 0], [0, 6, 5, 8, 0], [0, 3, 7, 1, 0]]

# 画出坐标点
x, y = zip(*points)
plt.scatter(x, y)

# 画出路线
colors = ['r', 'g', 'b']
for i, route in enumerate(routes):
    x, y = zip(*[points[j] for j in route])
    plt.plot(x, y, color=colors[i])

# 显示图像
plt.show()

运行上述代码,即可得到以下配送路线图:

配送路线图

Python 绘制配送路线图:三辆车示例

原文地址: https://www.cveoy.top/t/topic/orW6 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录