#import astropy #import h5py #import math #import numpy as np #from scipy.constants import c #from astropy.io import fits #import subprocess #import statistics as stat #from operator import mul #from operator import truediv #import itertools as it # plotting variables from setup_matplotlib import * from matplotlib.ticker import MaxNLocator width = 8.8 # Create the plot #fig = plt.figure(figsize=(1.25*cm2inch(width), 6./8.*cm2inch(width))) fig = plt.figure(figsize=(1.25*cm2inch(width), 1.25*cm2inch(width))) #ax = fig.add_subplot(111) ax = fig.add_subplot(111,aspect='equal') #ax.set_aspect('equal') #end plotting variables betafilnavn33="/mn/stornext/d5/unnif/sindex_bp/coswmap23_coswmap33ab/combab_011-195/ut_sample_betas_invvar.txt" b33=[] u33=[] with open(betafilnavn33) as f_p33: for line in f_p33: data = line.split() b33.append(float(data[1])) u33.append(float(data[2])) f_p33.close() betafilnavn30="/mn/stornext/d5/unnif/sindex_bp/coswmap23_cos30ab/combab_011-195/ut_sample_betas_invvar.txt" b30=[] u30=[] with open(betafilnavn30) as f_p30: for line in f_p30: data = line.split() #rx.append(float(data[0])) #plot the point next to the first two b30.append(float(data[1])) u30.append(float(data[2])) f_p30.close() # a plot with numbers n = np.arange(1, 25) colors=['#1f77b4', '#ff7f0e', '#2ca02c', '#d62728', '#9467bd', '#8c564b', '#e377c2', '#7f7f7f', '#bcbd22', '#17becf','#1f77b4', '#ff7f0e', '#2ca02c', '#d62728', '#9467bd', '#8c564b', '#e377c2', '#7f7f7f', '#bcbd22', '#17becf','#1f77b4', '#ff7f0e', '#2ca02c', '#d62728', '#9467bd', '#8c564b', '#e377c2', '#7f7f7f', '#bcbd22', '#17becf'] for xi, yi, ux, uy, txt, col in zip(b33, b30, u33, u30, n, colors): #ax.scatter(xi, yi, marker=f'${txt}$') #markers, caps, bars = plt.errorbar(xi,yi, xerr=ux, yerr=uy, marker=f'${txt}$', capsize=2) #, alpha=0.5) #, linewidth=0.5, color='black',markersize=3,capsize=2,ls='none') markers, caps, bars = plt.errorbar(xi,yi, xerr=ux, yerr=uy, marker='.', capsize=2, color=col) #, alpha=0.5) #, linewidth=0.5, color='black',markersize=3,capsize=2,ls='none') [bar.set_alpha(0.35) for bar in bars] [cap.set_alpha(0.35) for cap in caps] #sette paa text xt=xi yt=yi #oppe til hoyre if txt==6 or txt==7 or txt==8 or txt==9 or txt==12 or txt==18 or txt==21 or txt==22 or txt==23: xt=xi+0.018; yt=yt+0.003 ha='left' ; va='bottom' if txt==9: xt=xi+0.025 #oppe til venstre elif txt==3 or txt==4 or txt==5 or txt==11 or txt==15 or txt==17 or txt==19 or txt==20: xt=xi-0.01; yt=yt+0.003 ha='right' ; va='bottom' if txt==15 or txt==5: xt=xi #-0.001 if txt==3 or txt==5: yt=yi #nede til venstre elif txt==1 or txt==2 or txt==10 or txt==13 or txt==14: xt=xi-0.005; yt=yt-0.015 ha='right' ; va='top' #nede til hoyre elif txt==16 or txt==24: xt=xi+0.005; yt=yt-0.015 ha='left' ; va='top' ax.annotate(txt, (xi, yi), xytext=(xt, yt), color=col, fontsize=9, horizontalalignment=ha, verticalalignment=va) #['#1f77b4', '#ff7f0e', '#2ca02c', '#d62728', '#9467bd', '#8c564b', '#e377c2', '#7f7f7f', '#bcbd22', '#17becf'] #for i, txt in enumerate(n): # ax.annotate(txt, (z[i], y[i])) # a x plot #plt.plot(b33, b30, marker='x', color='black', markersize=3, ls='none') print("b33 "+str(min(b33))+" "+str(max(b33))) print("b30 "+str(min(b30))+" "+str(max(b30))) # straight line xlin = np.linspace(-6,-1,100) plt.plot(xlin,xlin, color='gray',linestyle='--', linewidth=0.5, alpha=0.9) # general plot parameters plt.xlim(-4.8,-2.2) plt.ylim(-4.8,-2.2) # plt.xlim(0.2,24.8) # plt.xticks([1,5, 10, 15, 20, 24]) #ax.set_xticks([2,3,4], minor=True) ax.minorticks_on() plt.xlabel(r"Spectral index, $\beta_\mathrm{s}$ 23/33 GHz", fontsize=10) plt.ylabel(r"Spectral index, $\beta_\mathrm{s}$ 23/30 GHz", fontsize=10) #;plt.xlabel(r"Region number", fontsize=10); #leg = plt.legend(frameon=True, loc='lower right', prop={'size':7}) leg = plt.legend(frameon=True, loc='upper left', prop={'size':7}) # remove box around legend leg.get_frame().set_edgecolor("white") leg.get_frame().set_alpha(.0) plt.show() plt.savefig("xy_regions.png", bbox_inches='tight', bbox_extra_artists=[],pad_inches=0.03) #ut_sample_scatter_alpha_spectral_index.txt