def plot_four(plot_data): fig = plt.figure(figsize=(20, 10)) # gs = gridspec.GridSpec(1, 2, height_ratios=[1, 2]) ax = fig.add_subplot(223, projection='3d') ax.scatter(plot_data['sx'], plot_data['sy'], plot_data['sz']) ax.plot(plot_data['sx'], plot_data['sy'], plot_data['sz'], color='b') ax.view_init(azim=0, elev=90) #xy plane plt.xticks(fontsize=10) ax.set_title('Displacement Projection in xy Plane',size=20) ax2 = fig.add_subplot(224, projection='3d') ax2.scatter(plot_data['sx'], plot_data['sy'], plot_data['sz']) ax2.plot(plot_data['sx'], plot_data['sy'], plot_data['sz'], color='b') ax2.view_init(azim=0, elev=45) ax2.set_title('Displacement',size=20) ax3 = fig.add_subplot(221) # 50 represents number of points to make between T.min and T.max xnew = np.linspace(0,8,50) spl = make_interp_spline(pd.Series(range(9)), plot_data['tilt1'], k=3) # type: BSpline x = spl(xnew) spl = make_interp_spline(pd.Series(range(9)), plot_data['tilt2'], k=3) # type: BSpline y = spl(xnew) spl = make_interp_spline(pd.Series(range(9)), plot_data['compass'], k=3) # type: BSpline z = spl(xnew) ax3.plot(x,"b-",label='tilt1') ax3.plot(y,"r-",label='tilt2') ax3.plot(z,"g-",label='compass') ax3.legend(loc="lower left",prop={'size': 20}) ax3.set_title('Orientation Plot (degree)',size=20) ax3.tick_params(labelsize=20) ax4 = fig.add_subplot(222) # x = gaussian_filter1d(plot_data['ax'], sigma=1) # y = gaussian_filter1d(plot_data['ay'], sigma=1) # z = gaussian_filter1d(plot_data['az'], sigma=1) # mag = gaussian_filter1d(plot_data['accelerometer'], sigma=1) spl = make_interp_spline(pd.Series(range(9)), plot_data['ax'], k=3) # type: BSpline x = spl(xnew) spl = make_interp_spline(pd.Series(range(9)), plot_data['ay'], k=3) # type: BSpline y = spl(xnew) spl = make_interp_spline(pd.Series(range(9)), plot_data['az'], k=3) # type: BSpline z = spl(xnew) spl = make_interp_spline(pd.Series(range(9)), plot_data['accelerometer'], k=3) # type: BSpline mag = spl(xnew) ax4.plot(x/1000,"c--",label='ax') ax4.plot(y/1000,"g--",label='ay') ax4.plot(z/1000,"b--",label='az') ax4.plot(mag,"r-",label='Acc') ax4.legend(loc="lower left",prop={'size': 20}) ax4.set_title('Acceleration Plot (g)',size=20) ax4.tick_params(labelsize=20) plt.tight_layout() plt.show() fig.savefig('FourInOne.png')
def multiplot_gen_property_type(): # # font = {'family': 'Liberation Serif', # 'weight': 'normal', # 'size': 15 # } # # # play around with the font size if it is too big or small # matplotlib.rcParams['axes.titlesize'] = 12 # matplotlib.rcParams['axes.labelsize'] = 12 # matplotlib.rc('font', **font) # # matplotlib.rcParams['text.usetex'] = True # matplotlib.rcParams['pdf.fonttype'] = 42 # matplotlib.rcParams['pdf.use14corefonts'] = True x = list(data.keys()) y1=[] y2=[] y3=[] y4=[] y5=[] y6=[] for year in data.keys(): for option_name, count in data[year].items(): if option_name == 'domain': y1.append(count) if option_name == 'sitekey': y2.append(count) if option_name == 'third-party': y3.append(count) if option_name == 'websocket': y4.append(count) if option_name == 'webrtc': y5.append(count) if option_name == 'csp': y6.append(count) plt.plot(x, y1,'-o',label='domain') plt.plot(x, y2,'-v',label='sitekey') plt.plot(x, y3,'-^',label='third-party') plt.plot(x, y4,'-<',label='websocket') plt.plot(x, y5,'->',label='webrtc') plt.plot(x, y6,'-1',label='csp') plt.xticks(rotation='vertical') plt.xlabel('Year') plt.ylabel('Count') plt.legend(ncol=2) plt.tight_layout() plt.savefig('easylist-property-type.pdf ', format='pdf', dpi=1200)
def plot_average(collected_results, versions, args, plot_std=True): test_type = args.test_type model_name = args.model means, stds = [], [] for version in versions: data = collected_results[version] if (plot_std): means.append(np.mean(data)) stds.append(np.std(data)) else: means.append(data) means = np.array(means) stds = np.array(stds) if (test_type == "size" or test_type == "allsize"): x = ["0%", "20%", "40%", "60%", "80%", "100%"] elif (test_type == "accdomain" or test_type == "moredomain"): x = [0, 1, 2, 3, 4] else: x = versions color = 'blue' plt.plot(x, means, color=color) if (plot_std): plt.fill_between(x, means - stds, means + stds, alpha=0.1, edgecolor=color, facecolor=color, linewidth=1, antialiased=True) plt.xticks(np.arange(len(x)), x, fontsize=18) plt.yticks(fontsize=18) plt.xlabel(XLABELS[test_type], fontsize=18) plt.ylabel('average absolute effect size', fontsize=18) plt.title("Influence of {} on bias removal \nfor {}".format( TITLES[test_type], MODEL_FORMAL_NAMES[model_name]), fontsize=18) plt.tight_layout() plot_path = os.path.join( args.eval_results_dir, "plots", "{}-{}-avg{}.png".format(model_name, test_type, "-std" if plot_std else "")) plt.savefig(plot_path)
def bar_graph(category, age_grp, sex, x, y, year=None, country=None): plt.figure() plt.ylabel('ATE = Y1 - Y0') plt.xlabel('Years') plt.bar(range(len(x)), x, align='center') plt.xticks(range(len(x)), y, rotation='vertical') if country: plt.title("%s Suicide Rates for WC; %s ages %s" % (country, sex, age_grp)) name = country + sex + age_grp + '.png' # plt.show() plt.tight_layout() plt.savefig('./graphs/Countries' + '/' + sex + '/' + name.replace(' ', '_')) elif year: plt.title("Change in Suicide Rates per Country in %s; %s ages %s" % (year, sex, age_grp)) name = category + sex + str(year) + age_grp + '.png' # plt.show() plt.tight_layout() plt.savefig('./graphs/' + category + '/' + sex + '/' + str(year) + '/' + name.replace(' ', '')) else: plt.title("Change in Suicide Rates in %s Countries; %s ages %s" % (category, sex, age_grp)) name = category + sex + age_grp + '.png' # plt.show() plt.tight_layout() plt.savefig('./graphs/' + category + '/' + sex + '/' + name.replace(' ', ''))
plt.ylabel('K-mer density [0-1] for word '+word_hash) avg_freq = float(frequency)/float(seq_len) uniform = 1 / ( 4 ** len(word_hash) ) print('Average frequency distribution: ', avg_freq) print('Expected uniform distribution: ', uniform) print('Total accounted for: ', total) plt.plot([0, vector_l], [avg_freq, avg_freq], color="blue", label='Average frequency distribution') plt.plot([0, vector_l], [2*avg_freq, 2*avg_freq], color="cyan", label='Average frequency distribution') plt.plot([0, vector_l], [uniform, uniform], color="orange", label='Uniform distribution') plt.plot([0, vector_l], [observed_prob, observed_prob], color="green", label='Observed probability') leg = axes.legend() plt.savefig(filepath+'.png') labels = [item.get_text() for item in axes.get_xticklabels()] labels = [int(item) * seq_len/vector_l for item in labels] labels = [ "{:.2E}".format((item)) for item in labels] axes.set_xticklabels(labels) plt.tight_layout() plt.savefig(filepath+'.png') print('\nSaved figure at ', filepath+'.png') #plt.plot(x,y)
def multiplot_gen_content_type(): font = {'family': 'Liberation Serif', 'weight': 'normal', 'size': 15 } # play around with the font size if it is too big or small matplotlib.rcParams['axes.titlesize'] = 12 matplotlib.rcParams['axes.labelsize'] = 12 matplotlib.rc('font', **font) # matplotlib.rcParams['text.usetex'] = True matplotlib.rcParams['pdf.fonttype'] = 42 matplotlib.rcParams['pdf.use14corefonts'] = True x = list(data.keys()) y1 =[] y2 =[] y3 =[] y4 =[] y5 =[] y6 =[] y7 =[] y8 =[] y9 =[] y10 =[] y11 =[] y12 =[] y13 =[] y14 =[] y15 =[] print("---",y1) for year in data.keys(): for option_name, count in data[year].items(): if option_name == 'script': y1.append(count) if option_name == 'xmlhttprequest': y2.append(count) if option_name == 'document': y3.append(count) if option_name == 'elemhide': y4.append(count) if option_name == 'subdocument': y5.append(count) if option_name == 'image': y6.append(count) if option_name == 'popup': y7.append(count) if option_name == 'ping': y8.append(count) if option_name == 'stylesheet': y9.append(count) if option_name == 'object': y10.append(count) if option_name == 'generichide': y11.append(count) if option_name == 'font': y12.append(count) if option_name == 'media': y13.append(count) if option_name == 'genericblock': y14.append(count) if option_name == 'other': y15.append(count) print("x-->",x) print("y-->",y1) print("y-->",y2) plt.xticks(rotation='vertical') plt.xlabel('Year') plt.ylabel('Count') plt.legend(ncol=2) plt.tight_layout() plt.savefig('easylist-content-type.pdf ', format='pdf', dpi=1200)
BergondGCs = Bergond[Bergond['Type'] =='gc'] BergondGCs[['RAJ2000', 'DEJ2000']].to_csv('/Volumes/VINCE/OAC/imaging/BergondGCs_RADEC.reg', index = False, sep =' ', header = None) cat1 = coords.SkyCoord(GCs['RA_g'], GCs['DEC_g'], unit=(u.degree, u.degree)) cat2 = coords.SkyCoord(BergondGCs['RAJ2000'], BergondGCs['DEJ2000'], unit=(u.degree, u.degree)) index,dist2d, _ = cat1.match_to_catalog_sky(cat2) mask = dist2d.arcsec < 0.3 new_idx = index[mask] VIMOS = GCs.ix[mask].reset_index(drop = True) BergondMatch = BergondGCs.ix[new_idx].reset_index(drop = True) print len(BergondMatch) x = VIMOS['VREL_helio'] xerr = VIMOS['VERR'] y = BergondMatch['HRV'] yerr = BergondMatch['e_HRV'] plt.errorbar(x, y, yerr= yerr, xerr = xerr, fmt = 'o', c ='red',label = 'Bergond et al.') plt.rc('text', usetex=True) plt.rc('font', family='serif') plt.xlabel(r'Velocity from this work [km s$^-1$ ]') plt.ylabel(r'Velocity from the literature [km s$^-1$ ]') plt.legend(loc = 'upper left') plt.tight_layout() plt.show() print 'rms (VIMOS - Bergond) GCs = ', np.std(x-y)