2016-04-10 16 views
0

Bu başlangıç ​​çizimim var. Bir yoğunluk temsilini çizdirirkenPython - Plot eksenleri, yoğunluk çiziminde descale

enter image description here

İşte

bu kodudur

,

x = subhalos['SubhaloVelDisp'] 
y = (subhalos['SubhaloBHMass'] * 1e10/0.704) # in units of M_sol h^-1 

logx = np.log(x) 
logy = np.log(y) 

plt.plot(logx, logy, '.') 

plt.ylabel('$\log(M_{BH}$/M$_{\odot}$)') 
plt.xlabel(' $\log(\sigma_{1D}$/km s$^{-1}$)') 
plt.title('$M_{BH}-\sigma$ relation') 

Şimdi, benim sonuçları, başarılı olan bana bu vererek, AMA benim eksende benim birimleri tamamen değişti yine de ilk çizimdeki şekli hala korur.

x = subhalos['SubhaloVelDisp'] 
y = subhalos['SubhaloBHMass'] * 1e10/0.704 # in units of M_sol h^-1 


X = np.log10(x) 
Y = np.log10(y) 

x1 = X[np.isfinite(X)] 
y1 = Y[np.isfinite(Y)] 

x1.resize(y1.shape) 

xy = np.vstack([x1,y1]) 
z = stats.gaussian_kde(xy)(xy) 

idx = z.argsort() 
x,y,z = x1[idx],y1[idx],z[idx] 

fig, ax = plt.subplots() 
ax.scatter(X,Y,c=z, s=25, edgecolor='') 
plt.ylabel('$\log(M_{BH}$/M$_{\odot}$)') 
plt.xlabel(' $\log(\sigma_{1D}$/km s$^{-1}$)') 
plt.title('$M_{BH}-\sigma$ relation') 

anahtar şeyler

enter image description here

günlük şeklinde iki diziyi x ve y geçerken, ben dizide NaN değerlerini alacak vardır. Her ikisini de np.isfinite modülünden çalıştırıyorum ve her iki diziyi de aynı şekilde olacak şekilde yeniden boyutlandırıyorum.

Değerlerimin benim eksenlerimde değişmesi için burada neler oluyor?

cevap

1

Ben bütün diziyi anlamadı ama eksenlerde farkı benziyor gidip ikinciye

logx = np.log(x) 
logy = np.log(y) 
ilk örnekteki

ve

X = np.log10(x) 
Y = np.log10(y) 

kullanılan olmasıdır.