print(figname) if figure_options.get('solid_dashed_contours_legend'): solid_label,dashed_label=figure_options['solid_dashed_contours_legend'] solid_1 = plt.Line2D((0,1),(0,0), color='r',linewidth=2, linestyle='solid') solid_2 = plt.Line2D((0,1),(0,0), color='b',linewidth=2, linestyle='solid') dashed_1 = plt.Line2D((0,1),(0,0), color='r',linewidth=2, linestyle='dashed') dashed_2 = plt.Line2D((0,1),(0,0), color='b',linewidth=2, linestyle='dashed') bf1 = plt.Line2D((0,1),(0,0), color='g',marker='*',markeredgewidth=1.5, markeredgecolor='g',markersize=15, linestyle='') bf2 = plt.Line2D((0,1),(0,0), color='none',marker='*',markeredgewidth=1.5, markeredgecolor='g',markersize=15, linestyle='') handles=[solid_1,solid_2,dashed_1,dashed_2,bf1,bf2] dchi2_1,dchi2_2=r' $\Delta\chi^2=\/2.30$',r' $\Delta\chi^2=\/5.99$' labels=[solid_label+dchi2_1,solid_label+dchi2_2,dashed_label+dchi2_1,dashed_label+dchi2_2, solid_label+' best fit',dashed_label+' best fit'] axes.legend(handles,labels,loc='best',fontsize=10,numpoints=1,frameon=False) legend_options = figure_options.get('legend') if isinstance(legend_options, dict): labels=[] handles=[] handles_labels_list = legend_options['handles_labels'] for handle_label_options in handles_labels_list: label = handle_label_options['label'] line_2d_kwargs = handle_label_options.get('line_2d_kwargs') if isinstance(line_2d_kwargs, dict): handle = plt.Line2D((0,1),(0,0), **line_2d_kwargs) patch_kwargs = handle_label_options.get('patch_kwargs') if isinstance(patch_kwargs, dict): handle = Patch(**patch_kwargs) labels.append(label) handles.append(handle)
mu=0.92 sigma_plus=0.21 sigma_min=0.2 br=numpy.linspace(0,3,1000) chi2=2*(mu*sqrt(-(-br/mu+1)*(8*sigma_plus/mu -8*sigma_min/mu)+ \ (-sigma_plus/mu -sigma_min/mu)**2)-sigma_plus-sigma_min)**2\ /(8*(sigma_plus-sigma_min)**2); axes.plot(br,chi2,c='r') if figure_options.get('g-2_constraint'): gm2=numpy.linspace(-1e-9,10e-9,1000) mu=3.02e-09 sigma=9.0244113381427819e-10 chi2=((mu-gm2)/sigma)**2 axes.plot(gm2,chi2,c='r') legend_options_list = figure_options.get('legend') if isinstance(legend_options_list,list): labels=[] handles=[] for legend_options in legend_options_list: label = legend_options['label'] line_2d_kwargs = legend_options.get('line_2d_kwargs') if isinstance(line_2d_kwargs, dict): handle = plt.Line2D((0,1),(0,0), **line_2d_kwargs) patch_kwargs = legend_options.get('patch_kwargs') if isinstance(patch_kwargs, dict): handle = Patch(**patch_kwargs) labels.append(label) handles.append(handle) axes.legend(handles, labels, loc='upper right',numpoints=1,frameon=False) plt.savefig(figname)