05 Python Matplotlib library to draw a scatterplot

05 Draw a scatterplot

# 绘制散点图的两种方法
x = np.linspace(0, 10, 100)
plt.scatter(x, np.sin(x))
plt.show()
# 或
plt.plot(x, np.cos(x), 'o')
plt.show()

Plot plots of different colors and sizes

x = np.linspace(0, 10, 100) 		#创建0-10之间,100个等差数值
np.random.seed(0) 					# 执行多次但是每次获取的数值均为相等
x1 = np.random.rand(100)
y1 = np.random.rand(100)
print(x)

#绘制散点图
plt.scatter(x1, y1)
plt.show()
Published 36 original articles · praised 0 · visits 627

Guess you like

Origin blog.csdn.net/Corollary/article/details/105391693