low,high,nbins=numpy.log10(b['low']), numpy.log10(b['high']), b['nbins'] half_bin=0.5*(high-low)/nbins bin_edges.append(numpy.logspace(low,high,nbins+1)) bin_centres.append(numpy.logspace(low+half_bin,high-half_bin,nbins)) #start figure X,Y=numpy.meshgrid(bin_centres[0],bin_centres[1]) figsize = figure_options.get('figsize',[8, 6]) fig=plt.figure(figsize=figsize) axes_rect = figure_options.get('axes_rect',[0.17, 0.15, 0.77, 0.75]) axes=fig.add_axes(axes_rect) axes.tick_params(axis='both',which='major',labelsize=20) xlabel=axes_details[0].get('texname',axes_details[0]['name']) ylabel=axes_details[1].get('texname',axes_details[1]['name']) label_fontsize=figure_options.get('label_fontsize',20) axes.set_xlabel(xlabel,fontsize=label_fontsize) axes.set_ylabel(ylabel,fontsize=label_fontsize) axes.set_xlim([binnings[0]['low'],binnings[0]['high']]) axes.set_ylim([binnings[1]['low'],binnings[1]['high']]) if binnings[0]['type'] == 'log': axes.set_xscale('log') if binnings[1]['type'] == 'log': axes.set_yscale('log') if not figure_options.get('suppress_ticks_from_axes',False): if axes_details[0].get('xticks',False) and binnings[0]['type']=='linear': low,high,step=binnings[0]['low'],binnings[0]['high'],axes_details[0]['xticks'] axes.set_xticks(numpy.arange(low,high*1.001,step)) if axes_details[1].get('yticks',False) and binnings[1]['type']=='linear': low,high,step=binnings[1]['low'],binnings[1]['high'],axes_details[1]['yticks'] axes.set_yticks(numpy.arange(low,high*1.001,step)) text_box_options_list = figure_options.get('text_boxes',False) if isinstance(text_box_options_list, list):
entries_plot=cw.get_1d_hist(filename,entries_plotname,nxbins) if layer_options.get('dchi2_mode',False): #chi2_minimum=cw.get_min_reference(filename) chi2_minimum = cw.get_1d_minimum(filename,plotname,nxbins) if chi2_minimum==1e9: chi2_minimum=layer_options.get('chi2_minimum',numpy.min(plot)) plot=plot-chi2_minimum color=layer_options.get('color') linestyle=layer_options.get('linestyle') linewidth=layer_options.get('linewidth',2) label = layer_options.get('label') axes.plot(bin_centres,plot,linewidth=linewidth,c=color, linestyle=linestyle) #FIXME: maybe ylim shouldn't be a property of the layer axes.set_ylim([layer_options.get('ymin',0),layer_options.get('ymax',9)]) axes.set_ylabel(layer_options.get('ylabel',''),fontsize=20) #FIXME: this is an ugly way to get the 95% CL lower limit out if figure_options.get('chi2_eq_4_limit'): f=scipy.interpolate.interp1d(bin_centres,plot) xnew=numpy.linspace(bin_centres[0],bin_centres[-1],1000) ynew=f(xnew) try: for i in range(999): if ynew[i]>4 and ynew[i+1]<4: print('{}:{}'.format(xaxis_details['name'],int(xnew[i+1]))) axes.plot(xnew[i+1],ynew[i+1],'o') except IndexError: print('limit not found for {}'.format(xaxis_details['name'])) if not figure_options.get('chi2_eq_4_limit'): print(figname)