有没有办法优雅地在圆圈内绘制箭头

2 python matplotlib

我正在尝试在单位圆中绘制单位向量。

这是代码

vunit = 1/np.sqrt(2)
vec1 = [vunit,vunit]
thetas = np.arange(-np.pi, np.pi, .05)
coordinates = np.vstack((np.cos(thetas),np.sin(thetas)))

plt.figure(figsize = (6,6))
plt.xlim(-3,3)
plt.ylim(-3,3)
plt.scatter(coordinates[0,:],coordinates[1,:],s=.1)
plt.arrow(0, 0, vec1[0], vec1[1], head_width=0.15, color='r')
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

一切都OK,除了箭头的头在圆的外面。

所以,我修改vec1很难

vec1 = [vunit-.1,vunit-.1]
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

该图看起来更好,我可以更精细地修改vec1,但是修复似乎很丑。有没有办法让箭头优雅地出现在圆圈内

unu*_*tbu 5

用途length_includes_head=True

import numpy as np
import matplotlib.pyplot as plt

vunit = 1/np.sqrt(2)
vec1 = [vunit,vunit]
thetas = np.arange(-np.pi, np.pi, .05)
coordinates = np.vstack((np.cos(thetas),np.sin(thetas)))

plt.figure(figsize = (6,6))
plt.xlim(-3,3)
plt.ylim(-3,3)
plt.scatter(coordinates[0,:],coordinates[1,:],s=.1)
plt.arrow(0, 0, vec1[0], vec1[1], head_width=0.15, color='r', length_includes_head=True)
plt.show()
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明