我试图对存储在ndarray中的一些数据做一个柱状图。柱状图是我在python程序中对一个类进行的一组分析的一部分。下面是代码不起作用的部分。在
def histogram(self, iters):
samples = T.MCMC(iters) #Returns an [iters,3,4] ndarray
histAC = plt.figure(self.ip) #plt is matplotlib's pyplot
self.ip+=1 #defined at the beginning of the class to start at 0
for l in range(0,4):
h = histAC.add_subplot(2,(iters+1)/2,l+1)
for i in range(0,0.5*self.chan_num):
intAvg = mean(samples[:,i,l])
print intAvg
for k in range(0,iters):
samples[k,i,l]=samples[k,i,l]-intAvg
print "Samples is ",samples
h.hist(samples,bins=5000,range=[-6e-9,6e-9],histtype='step')
h.legend(loc='upper right')
h.set_title("AC Pulse Integral Histograms: "+str(l))
figname = 'ACHistograms.png'
figpath = 'plot'+str(self.ip)
print "Finished!"
#plt.savefig(figpath + figname, format = 'png')
这将显示以下错误消息:
^{pr2}$我发现的唯一的搜索结果是相同的两个对话的多个副本,从中我了解到python柱状图不喜欢得到空数组,这就是为什么我将print语句添加到行的正上方,这使我很难确保数组不是空的。在
以前有人遇到过这个错误吗?在
目前没有回答
相关问题 更多 >
编程相关推荐