我繪製使用python通過導入文本文件中的數據的散點圖,我想與x軸值0刪除點這是我寫刪除點
mat0 = genfromtxt("herbig0.txt");
mat1 = genfromtxt("coup1.txt");
pyplot.xlim([-2,6])
pyplot.ylim([26,33])
colors=['red', 'blue','green']
pyplot.scatter(mat0[:,13], mat0[:,4], label = "herbig stars", color=colors[0]);
if mat1[:,2] != 0:
pyplot.scatter(mat1[:,2], mat1[:,9], label = "COUP data of SpT F5-M6 ", color=colors[1]);
pyplot.scatter(mat1[:,2], mat1[:,10], label = "COUP data of SpT B0-F5", color=colors[2]);
pyplot.legend();
pyplot.xlabel('Log(Lbol) (sol units)')
pyplot.ylabel('Log(Lx) (erg/s)')
pyplot.title('Lx vs Lbol')
pyplot.show();
程序這是我的當我不使用if語句時輸出graph。 我想刪除x軸值爲零的所有藍色點。請建議更改。如果我使用if語句並且所有的點都消失了。
而不是刪除點一旦繪製你最好的選擇是根本不要將這些值放在首位。即在mat1 [:,2],mat1 [:,9]上過濾,因爲這些列是藍點的來源。 – miraculixx