问题描述
我正在用 python 模拟弹丸运动,有一件事我需要帮助。当我使用 plt.legend()
来显示对应于每条线的角度(在我的图表的右上角)时,它们以弧度形式出现。如何转换它们以使其以角度形式出现,例如 30 degree
、60 degree
等?
图表:
import numpy as np
import matplotlib.pyplot as plt
import math
#theta=pi/3
V=38.5 #speed
t=np.arange(0,19,0.1)
angle = math.pi/12
angle_list=[]
while angle < math.pi/2:
x=V*np.cos(angle)*t
y=V*np.sin(angle)*t+(0.5*-9.8*t**2)
plt.ylim([0,80])
plt.xlim([0,170])
print(x,y)
plt.plot(x,y)
angle_list.append(angle)
angle+=math.pi/12
plt.xlabel("range")
plt.ylabel("height")
plt.title('Projectile Motion With Multiple Angles')
plt.legend(angle_list)
plt.show()
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)