python中怎么输入角度_python – 在Matplotlib中绘制两行之间的角度的最佳方式

您可以使用

matplotlib.patches.Arc绘制相应角度测量的弧.

绘制角弧:

定义一个可以使用2个matplotlib.lines.Line2D对象的函数,计算角度并返回一个matplotlib.patches.Arc对象,您可以将其添加到绘图中.

def get_angle_plot(line1,line2,offset = 1,color = None,origin = [0,0],len_x_axis = 1,len_y_axis = 1):

l1xy = line1.get_xydata()

# Angle between line1 and x-axis

slope1 = (l1xy[1][1] - l1xy[0][2]) / float(l1xy[1][0] - l1xy[0][0])

angle1 = abs(math.degrees(math.atan(slope1))) # Taking only the positive angle

l2xy = line2.get_xydata()

# Angle between line2 and x-axis

slope2 = (l2xy[1][3] - l2xy[0][4]) / float(l2xy[1][0] - l2xy[0][0])

angle2 = abs(math.degrees(math.atan(slope2)))

theta1 = min(angle1,angle2)

theta2 = max(angle1,angle2)

angle = theta2 - theta1

if color is None:

color = line1.get_color() # Uses t

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值