在我的代码中,我假设2D圆是一个类似于地球但蓝色的行星。我想在蓝色圆圈的边上画出两个相互垂直的向量a,u,r,但是我不知道如何把垂直向量a,u,r放在圆的顶部或底部。What I want to plot in pythonnot circular?quiver plot
下面是我使用的代码:
# Importing modules
import numpy as np
import matplotlib.pyplot as plt
g=9.81
Mmoon=7.3477e22 #mass of Moon
Mearth=5.972e24 #mass of Earth
R_min=356.5e6 #Perigee
R_max=406.7e6 #Apogee
R_avg = 0.5*(R_min + R_max)
r = 6.3781e6 #radius of Earth
theta=np.linspace(-1*np.pi,1*np.pi,180)
a_R=3*g*(Mmoon/Mearth)*((r/(R_avg))**3)*np.cos(theta)
#acceleration vector
a_h=3*g*(Mmoon/Mearth)*((r/(R_avg))**3)*np.cos(theta)*np.sin(theta)
#tangential acceleration vector
a_r=3*g*(Mmoon/Mearth)*((r/(R_avg))**3)*np.cos(theta)*np.cos(theta)
#perpendicular acceleration vector
plt.quiver([0,0 ], [0,0], [2,-2], [-4, -2], angles='xy',
scale_units='xy', scale=1)
plt.xlim(-10,10)
plt.ylim(-10,10)
earth = plt.Circle((0.5, 0.5), 0.2, color='blue') # (x_pos, y_pos), rad
fig, ax = plt.subplots() # note we must use plt.subplots, not
plt.subplot
#(or if you have an existing figure)
fig = plt.gcf()
ax = fig.gca()
ax.add_artist(earth)
任何帮助都将不胜感激!!在
Circle
命令在代码中什么也不做。为什么不使用scatter
圆形标记?在这里不使用散点是有意义的,因为这需要计算散点在数据单位中的点数。用圆圈代替是可以的。在
箭头被放置在根据月球轨道
R_avg
的位置。它们的长度在这里是任意的,但是你当然可以随意改变它。在相关问题 更多 >
编程相关推荐