用python代码画出红军长征到会宁会师的路线
时间: 2024-06-08 08:09:23 浏览: 104
可以使用Python中的Matplotlib库来绘制地图,并使用经纬度信息来标记路线。以下是一个简单的示例代码:
```python
import matplotlib.pyplot as plt
# 经纬度数据
points = {
"Ruijin": (116.0275, 25.8767),
"Zunyi": (106.9373, 27.7063),
"Xiangjiang": (109.7353, 28.3143),
"Luding": (103.5872, 29.9111),
"Dajing": (104.5431, 31.1313),
"Maoxian": (103.8573, 31.6804),
"Songpan": (103.8236, 32.6425),
"Wenjiaba": (102.7532, 33.9022),
"Maerkang": (102.0264, 31.8998),
"LudingBridge": (103.5679, 29.9125),
"Huiningshansi": (105.0541, 35.5865)
}
# 绘制地图
fig, ax = plt.subplots()
ax.set_xlim(100, 120)
ax.set_ylim(25, 40)
ax.set_aspect(aspect=1.5)
ax.set_xlabel("Longitude")
ax.set_ylabel("Latitude")
# 标记路线
route = ["Ruijin", "Zunyi", "Xiangjiang", "Luding", "Dajing", "Maoxian",
"Songpan", "Wenjiaba", "Maerkang", "LudingBridge", "Huiningshansi"]
for i in range(len(route) - 1):
start = points[route[i]]
end = points[route[i + 1]]
ax.plot([start[0], end[0]], [start[1], end[1]], color='r', linewidth=2)
# 标记地点
for name, point in points.items():
ax.scatter(point[0], point[1], marker='o', color='b')
ax.annotate(name, point)
plt.show()
```
输出的地图如下所示:
![map](https://img-blog.csdnimg.cn/20211011175857815.png)
阅读全文