2017-01-02 60 views
2

我試圖獨立於其他人旋轉其中一個註釋箭頭。我怎樣才能分開訪問它?下面是代碼:對組中的一個點進行格式化註釋

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權利這樣做?)幾度下來,也許讓谷歌一個是在另一側 charts

回答

1

更改該點的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 ')) 

enter image description here

您可以用參數玩,直到你找到你喜歡的!

編輯:

風格是不同的,因爲我不使用seaborn。重複相同,但在導入之前它給了我們:

import seaborn as sns 

rotate_seaborn

而是更類似,不是嗎?

+0

謝謝,這有幫助,但我想知道爲什麼連接看起來不同於地雷。顏色是不同的,它有可見的漸變,但我沒有看到你在代碼中改變了有關連接方式的任何東西 –

+0

@AlexT沒有漸變箭頭。只有黑色邊框很厚,並且會在箭頭處欺騙眼睛。 – Lucas

+0

現在我明白了,謝謝! –