为组中的一个点格式化注释
formatting annotation for one point from the group
我正在尝试独立于其他箭头旋转其中一个注释箭头。我怎样才能单独访问它?这是代码:
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
更相似,不是吗?
我正在尝试独立于其他箭头旋转其中一个注释箭头。我怎样才能单独访问它?这是代码:
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
更相似,不是吗?