首页 文章

Plt.Error上限在我的坐标处有箭头的尾端

提问于
浏览
0

两天来,我一直试图解决这个问题 . 我正在绘制上限,所以我需要向下箭头指向我的点 . 除此之外,我现在尝试使用Plt.Error获取这些箭头 . 问题是,箭头的尾端指向该点而不是尖端 .

下面,我展示了用于绘制此数据的代码,省略了我在数据中读取的部分 . 另外,我添加了两张图片 . 第一张图是结果图 . 第二个图像是该图中的黄色箭头,指的是点(10,.0076),您可以清楚地看到箭头的尾端指向该坐标 .

导入matplotlib.pyplot作为plt import numpy as np import 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)

1 回答

  • 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()
    

相关问题