我只需要在图形中添加箭头注释即可。我尝试了多种解决方案,但找不到正确的答案。
component_arrow = NewArrowAnnotation(100,100,200,200)
arrow.ComponentSetForegroundColor( 0, 1, 1 )
disp.ComponentAddChildAtEnd(arrow)
plt.annotate("Qatar",
`xy=(20, 20), xycoords='data',`
`xytext=(10^5, 90), textcoords='data',`
`arrowprops=dict(arrowstyle="->"),`
`)`
plt.annotate('qatar_income',
`xy=(6.28, 1),`
`xytext=(10, 4),`
`y='qatar_lifespan'`
`)`
qatar = now[now.country == 'Qatar']
qatar_income = qatar.income.values[0]
qatar_lifespan = qatar.lifespan.values[0]
sns.relplot(x="income",
`y="lifespan",`
`hue="6region",`
`size="population",`
`sizes=(40, 200),`
`alpha=.5,`
`palette="muted",`
`height=6,`
`data=now);`
plt.xscale('log')
plt.ylim([0, 90])
plt.title('The World in 2018')
plt.text(x=qatar_income-7000, y=qatar_lifespan+1, s = 'Qatar')
NewArrowAnnotation方法获取未定义的“ NewArrowAnnotation”。其他方法什么也没显示。