我正在尝试独立于其他箭头旋转其中一个注释箭头。我怎样才能单独访问它?这是代码:
for label, x, y in zip(rets.columns, rets.mean(), rets.std()):
plt.annotate(
label,
xy = (x, y), xytext = (180, 60),
textcoords = 'offset pixels', ha = 'left', va = 'center',
arrowprops = dict(arrowstyle = 'fancy', connectionstyle = 'angle3, angleA=0,angleB=90 '))
这里是图表,所以基本上我想将 MSFT 注释(与 connectionstyle 有关,对吗?)向下旋转几度,也许让 Google 的注释在另一侧 :
请您参考如下方法:
更改该点的 xytext。 例如:
x = np.random.randint(10, size=(5))
y = np.random.randint(10, size=(5))
labels = ['a', 'b', 'c', 'd', 'e']
plt.plot(x, y, 'o')
plt.xlim(-13, 25)
plt.ylim(-1, 15)
for label, i, j in zip(labels, x, y):
if label=='a' or label=='c':
plt.annotate(label, xy = (i, j), xytext = (-180, 60),
textcoords = 'offset pixels', ha = 'left', va = 'center',
arrowprops = dict(arrowstyle = 'fancy', connectionstyle = 'angle3, angleA=0,angleB=90 '))
else:
plt.annotate(label, xy = (i, j), xytext = (180, 60),
textcoords = 'offset pixels', ha = 'left', va = 'center',
arrowprops = dict(arrowstyle = 'fancy', connectionstyle = 'angle3, angleA=0,angleB=90 '))
您可以调整参数直到找到您喜欢的!
编辑:
因为我没有使用seaborn所以风格不一样。重复相同的操作,但在导入之前给我们:
import seaborn as sns
更相似,不是吗?
