plots.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:nmmn 作者: rsnemmen 项目源码 文件源码
def threehistsx(x1,x2,x3,x1leg='$x_1$',x2leg='$x_2$',x3leg='$x_3$',fig=1,fontsize=12,bins1=10,bins2=10,bins3=10):
    """
Script that pretty-plots three histograms of quantities x1, x2 and x3.

Arguments:
:param x1,x2,x3: arrays with data to be plotted
:param x1leg, x2leg, x3leg: legends for each histogram  
:param fig: which plot window should I use?

Example:
x1=Lbol(AD), x2=Lbol(JD), x3=Lbol(EHF10)

>>> threehists(x1,x2,x3,38,44,'AD','JD','EHF10','$\log L_{\\rm bol}$ (erg s$^{-1}$)')

Inspired by http://www.scipy.org/Cookbook/Matplotlib/Multiple_Subplots_with_One_Axis_Label.
    """
    pylab.rcParams.update({'font.size': fontsize})
    pylab.figure(fig)
    pylab.clf()

    pylab.subplot(3,1,1)
    pylab.hist(x1,label=x1leg,color='b',bins=bins1)
    pylab.legend(loc='best',frameon=False)

    pylab.subplot(3,1,2)
    pylab.hist(x2,label=x2leg,color='r',bins=bins2)
    pylab.legend(loc='best',frameon=False)

    pylab.subplot(3,1,3)
    pylab.hist(x3,label=x3leg,color='y',bins=bins3)
    pylab.legend(loc='best',frameon=False)

    pylab.minorticks_on()
    pylab.subplots_adjust(hspace=0.15)
    pylab.draw()
    pylab.show()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号