使用X和Y在matplotlib上使用python绘制轴承 我在地图上有3个已知位置,使用X,Y matplotlib使用子地块,我需要绘制其中一个塔的方位,并在地图上放置一条线 我目前使用X,Y作为起始位置,箭头/直线作为结束位置。但我想知道如何用轴承代替线的末端,而不是x,y。我目前正在研究向量,但运气不好
我的代码在下面,任何帮助都会很好使用X和Y在matplotlib上使用python绘制轴承 我在地图上有3个已知位置,使用X,Y matplotlib使用子地块,我需要绘制其中一个塔的方位,并在地图上放置一条线 我目前使用X,Y作为起始位置,箭头/直线作为结束位置。但我想知道如何用轴承代替线的末端,而不是x,y。我目前正在研究向量,但运气不好,python,python-3.x,pandas,matplotlib,vector,Python,Python 3.x,Pandas,Matplotlib,Vector,我的代码在下面,任何帮助都会很好 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
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()
将numpy导入为np
作为pd进口熊猫
将matplotlib.pyplot作为plt导入
输入数学
df=pd.read\u 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())
打印(BBox)
ruh_m=plt.imread('map.png')
图,ax=plt.子批次(图尺寸=(12,12))
最大散射(塔楼1x,塔楼1y,索德=1,阿尔法=0.5,c='红色',s=50,标签=“塔楼1”)
最大散射(tower2x,tower2y,zorder=1,alpha=0.5,c='blue',s=50,label=“2号塔”)
最大散射(tower3x,tower3y,zorder=1,alpha=0.5,c='绿色',s=50,label=“塔3”)
ax.注释(“,xy=(51.69557,-3.34197),xytext=**(51.69799,-3.34155)**,textcoords='data',
arrowprops=dict(arrowstyle=“这只是三角函数,不是吗?@jtlz2是的,如果我考虑了距离,我就不会有这些数据,如果我考虑了,会容易得多:(我只需要方位,如果我在所有三座塔楼上取方位,我就能得到我的位置,这就是我的最终目标。还有:,@jtlz2完美伙伴谢谢,我会试试的,看来这就是我要找的for@jtlz2这是上面的代码,它正在工作:)比ks的链接pal
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import math
df = pd.read_csv("Grids.csv")
df.head()
##
###X and Y Coordinates using www.openstreetmap.org
BBox = (df.longitude.min(), df.longitude.max(),
df.latitude.min(), df.latitude.max())
#Signal power
s1 = int(input("Enter power from tower 1: "))
s2 = int(input("Enter power from tower 2: "))
s3 = int(input("Enter power from tower 3: "))
#weight of signal
w1 = [s1 / ( s1 + s2 + s3 )]
w2 = [s2 / ( s1 + s2 + s3 )]
w3 = [s3 / ( s1 + s2 + s3 )]
#Tower locations
tower1_lat = np.array ([51.6985630])
tower1_lon = np.array ([-3.3410239])
##
tower2_lat = np.array ([51.6984699])
tower2_lon = np.array ([-3.3400422])
##
tower3_lat = np.array([51.6980743])
tower3_lon = np.array([-3.3406511])
#Your location using the above values
Locaion_Longitude = [tower1_lat * w1 + tower2_lat * w2 + tower3_lat * w3 ]
Locaion_Latitude = [tower1_lon * w1 + tower2_lon * w2 + tower3_lon* w3 ]
print (Locaion_Longitude)
print (Locaion_Latitude)
map_fig = plt.imread('map.png')
fig, ax = plt.subplots(dpi=150,figsize = (12,7))
ax.scatter(tower1_lon, tower1_lat, zorder=1, alpha= 0.5, c='red', s=50, label="Tower 1")
ax.scatter(tower2_lon, tower2_lat, zorder=1, alpha= 0.5, c='blue', s=50, label="Tower 2")
ax.scatter(tower3_lon, tower3_lat, zorder=1, alpha= 0.5, c='green', s=50, label="Tower 3")
ax.scatter(Locaion_Longitude, Locaion_Latitude, zorder=1, c='yellow', s=50, label="Your location")
ax.tick_params (axis='y', which='major', labelsize=5)
ax.tick_params (axis='x', which='major', labelsize=5)#axis settings
ax.set_title('Plotting Towers in Aberfan')
ax.set_xlim(BBox[0],BBox[1])
ax.set_ylim(BBox[2],BBox[3])
ax.imshow(map_fig, zorder=0, extent = BBox, aspect= "auto")
mng = plt.get_current_fig_manager() #full screen
mng.window.state("zoomed")
plt.legend()
plt.show()
enter code here