2017-07-11 28 views
0

兩天來我一直試圖解決這個問題。 我正在繪製上限,所以我需要向下指向箭頭指向我的要點。除此之外,我現在嘗試使用Plt.Error來獲取這些箭頭。問題是,箭頭的尾部指向點而不是尖端。Plt.Error上限在我的座標處有箭頭的尾端

下面,我展示了我繪製這些數據的代碼,省去了我讀取數據的部分。另外,我添加了兩張圖片。第一張圖片是結果圖。第二個圖像是該圖中的黃色箭頭,指的是點(10,.0076),您可以清楚地看到箭頭的尾端指向該座標。

進口matplotlib.pyplot如PLT 進口numpy的爲NP 進口pylab

f1 = plt.figure(0) 
plt.errorbar(days,fluxdensity,yerr=0.01,uplims=True,linestyle='none',markeredgewidth=5,elinewidth=5) 
plt.errorbar(days2, fluxdensity2, yerr=0.01,uplims=True,linestyle='none',markeredgewidth=5,elinewidth=5) 
plt.errorbar(days3, fluxdensity3, yerr=0.01,uplims=True,linestyle='none',markeredgewidth=5,elinewidth=5) 
plt.errorbar(days4, fluxdensity4,yerr=0.01,uplims=True,linestyle='none',markeredgewidth=5,elinewidth=5) 

plt.grid() 



plt.xlabel('Days Since Explosion', fontsize=18) 
plt.ylabel('Flux Density muJy', fontsize=16) 
plt.savefig('2014dtflux.pdf',format='pdf') 
plt.xlim((9.9,10.1)) 
plt.ylim((-.03,.12)) 
plt.show() 

Full Plot

Example of One Point Showing That The Tail of the Arrow is Pointing at (10,.0076)

回答

0

似乎要畫一個箭頭。要在matplotlib中繪製箭頭,可以使用FancyArrowPatch

enter image description here

import matplotlib.pyplot as plt 
import matplotlib.patches as patches 

style="Simple,tail_width=2,head_width=5,head_length=7" 
kw = dict(arrowstyle=style, color="k") 

a1 = patches.FancyArrowPatch((0,0.7), (0,0.5),**kw) 
a2 = patches.FancyArrowPatch((0,0.4), (0.0,0.3),**kw) 


for a in [a1,a2]: 
    plt.gca().add_patch(a) 

plt.xlim(-1,1) 

plt.show()