1. 程式人生 > >matplotlib(一):散點圖

matplotlib(一):散點圖

IT color src http 17. mark .py TP 數組

import numpy as np
import matplotlib.pyplot as plt
#產生測試數據
# x,y為數組
N = 50
x = np.random.rand(N)
y=np.random.randn(len(x))

fig = plt.figure()
ax1 = fig.add_subplot(111)
#設置標題
ax1.set_title(Scatter Plot)
#設置X軸標簽
plt.xlabel(X)
#設置Y軸標簽
plt.ylabel(Y)
#畫散點圖
ax1.scatter(x,y,c = g,marker = 1,s=200)
#設置圖標 plt.legend(x) #顯示所畫的圖 plt.show()

效果:

技術分享圖片

scatter參數匯總:

技術分享圖片

技術分享圖片

顏色:

技術分享圖片



matplotlib(一):散點圖