python繪制散點圖入門


import matplotlib.pyplot as plt

x_values = list(range(1,1001))
y_values = [x**2 for x in x_values]
plt.scatter(x_values, y_values,c=y_values,cmap=plt.cm.Blues, edgecolor='none', s=40)

#設置圖表標題並給坐標軸加上標簽
plt.title("Squares numbers", fontsize=24)
plt.xlabel("Value", fontsize=14)
plt.ylabel("Square of value", fontsize=14)

#設置刻度標記的大小
plt.tick_params(axis='both', which='major',labelsize=14)

#設置每個坐標軸的取值范圍
plt.axis([0,1100,0,1100000])
plt.show()
plt.savefig('squares_plot.png', bbox_inches='tight')


免責聲明!

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



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