python畫點線圖


參考自:https://www.jianshu.com/p/82b2a4f66ed7?utm_campaign=maleskine&utm_content=note&utm_medium=seo_notes&utm_source=recommendation

比較重要的是:
plt.plot(x, y, "c*-", ...)其中的"c*-"的 c 表示 cyan 是點的顏色,* 表示五角星 是點的形狀,- 表示實線 是線的類型。
plt.legend() 表示顯示各組點線的 label。

import numpy as np
import matplotlib.pyplot as plt
sd_Np=[2,4,6]
pf_Np=[2,4,6,8,10]
sdg7h11_Np=[2,4,6,8,10,12,14,16]
sd_t_iter=np.log([14,15,17])
pf_t_iter=np.log([136,144,155,172,202])
sdg7h11_t_iter=np.log([1700,1600,1710,1840,2000,2300,2600,3000])
plt.plot(sd_Np,sd_t_iter, "c*-", label="sd shell")
plt.plot(pf_Np,pf_t_iter, "gv-", label="pf shell")
plt.plot(sdg7h11_Np,sdg7h11_t_iter, "ro-", label="sdg7h11 shell")
plt.xlabel("Valence proton number $N_p$, with $N_n = N_p$",fontsize=14)
plt.ylabel("ln $t_{iter}$ (s)", fontsize=15)
plt.legend()
#plt.title("Timing for one iteration in the conjugate gradient method.",fontsize=14)
plt.savefig("t_iter.jpg")
#print(np.log(12), np.log(20), np.log(32))

以下是 marker 類型:
image


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM