bin_edges=[] bin_centres=[] for b in binnings: if b['type']=='linear': low,high,nbins=b['low'],b['high'],b['nbins'] half_bin=0.5*(high-low)/nbins bin_edges.append(numpy.linspace(low,high,nbins+1)) bin_centres.append(numpy.linspace(low+half_bin,high-half_bin,nbins)) elif b['type']=='log': 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')
#nxbins and nybins nxbins=binning['nbins'] #bin edges if binning['type']=='linear': low,high,nbins=binning['low'],binning['high'],binning['nbins'] half_bin=0.5*(high-low)/nbins bin_edges=numpy.linspace(low,high,nbins+1) bin_centres=numpy.linspace(low+half_bin,high-half_bin,nbins) elif binning['type']=='log': low,high,nbins=numpy.log10(binning['low']), numpy.log10(binning['high']), binning['nbins'] half_bin=0.5*(high-low)/nbins bin_edges=numpy.logspace(low,high,nbins+1) bin_centres=numpy.logspace(low+half_bin,high-half_bin,nbins) #start figure fig=plt.figure() axes=fig.add_axes(figure_options.get('axes_rect',[0.17, 0.15, 0.77, 0.75])) axes.tick_params(axis='both',which='major',labelsize=20) xlabel=xaxis_details.get('texname',xaxis_details['name']) label_fontsize=figure_options.get('label_fontsize',20) axes.set_xlabel(xlabel,fontsize=label_fontsize) axes.set_xlim([binning['low'],binning['high']]) if binning['type'] == 'log': axes.set_xscale('log') if not figure_options.get('suppress_ticks_from_axes',False): if xaxis_details.get('xticks',False) and binning['type']=='linear': low,high,step=binning['low'],binning['high'],xaxis_details['xticks'] axes.set_xticks(numpy.arange(low,high*1.001,step)) text_box_options_list = figure_options.get('text_boxes',False) if isinstance(text_box_options_list, list): for text_box_options in text_box_options_list: args=text_box_options.get('args')