コード例 #1
0
 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')
         kwargs={'verticalalignment':'top','transform':axes.transAxes,
                 'fontsize':20,'horizontalalignment':'left'}
         kwargs.update(text_box_options.get('kwargs',{}))
         axes.text(*args,**kwargs)
 #FIXME: there might be a better way of zipping an unzipping
 filenames, plotnames, layers_options = layers_details
 for filename, plotname, layer_options in zip(filenames, plotnames, layers_options):
     plot=cw.get_1d_hist(filename,plotname,nxbins)
     entries_plotname='{}_entries'.format(xaxis_details['name'])
     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
コード例 #2
0
        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))
#plot settings
if binnings[0]['type'] == 'log':
    plt.xscale('log')
plt.xlabel(axes[0])
nxbins=binnings[0]['nbins']

#get points
if len(axes)==1:
    chi2_plot=cw.get_1d_hist(rootfile,'{}_chi2'.format(plotname),nxbins)
    entries_plot=cw.get_1d_hist(rootfile,'{}_entries'.format(plotname),nxbins)
    plt.plot(bin_centres[0],chi2_plot,'o')
    plt.ylim([vmin,vmax])
    if args.best_fit:
        chi2_min=numpy.min(chi2_plot)
        rowid=int(entries_plot[chi2_plot==numpy.min(chi2_plot)])
    else:
        [(x,y)]=plt.ginput(1)
        id=numpy.where(bin_edges[0]>x)[0][0]-1
        print('Clicked points: {}: {}  {}: {}'.format(axes[0],x,'chi2',y))
        rowid=int(entries_plot[id])

#get plots
elif len(axes)==2:
    nybins=binnings[0]['nbins']