【发布时间】:2021-05-11 14:37:58
【问题描述】:
- 我在地图上使用
X, Y matplotlib使用子图有 3 个已知位置,我需要绘制其中一个塔的方位并在地图上放置一条线。 - 我目前使用 X、Y 作为开始位置,使用箭头/线作为结束位置。但想知道如何用轴承代替线尾代替x,y。我目前正在研究 Vectors,但没有运气。
我的代码低于任何帮助都会很棒
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import math
df = pd.read_csv("Book1.csv")
df.head()
tower1x = [51.69557]
tower1y = [-3.34197]
tower2x = [51.69673]
tower2y = [-3.34235]
tower3x = [51.69630]
tower3y = [-3.34090]
BBox = (df.longitude.min(), df.longitude.max(),
df.latitude.min(), df.latitude.max())
print (BBox)
ruh_m = plt.imread('map.png')
fig, ax = plt.subplots(figsize = (12,12))
ax.scatter(tower1x, tower1y, zorder=1, alpha= 0.5, c='red', s=50, label="Tower 1")
ax.scatter(tower2x, tower2y, zorder=1, alpha= 0.5, c='blue', s=50, label="Tower 2")
ax.scatter(tower3x, tower3y, zorder=1, alpha= 0.5, c='green', s=50, label="Tower 3")
ax.annotate("",xy=(51.69557,-3.34197), xytext=**(51.69799, -3.34155)**, textcoords='data',
arrowprops=dict(arrowstyle="<-", connectionstyle="arc3"),) # point from tower 1 using X,Y
ax.set_title('Plotting Towers in Aberfan')
ax.set_xlim(BBox[0],BBox[1])
ax.set_ylim(BBox[2],BBox[3])
ax.imshow(ruh_m, zorder=0, extent = BBox, aspect= 'equal')
plt.legend()
plt.show()
【问题讨论】:
-
这只是三角函数,不是吗?
-
@jtlz2 是的,如果我正在考虑距离,我虽然没有这些数据,但如果我这样做会容易得多:(我只需要轴承,如果我对所有三个都有轴承塔我得到我的位置那是我的最终目标
-
@jtlz2 完美的朋友谢谢我会试一试,看来这就是我要找的
标签: python python-3.x pandas matplotlib vector