python之matplotlib基础------散点图
程序员文章站
2024-01-15 17:43:46
...
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
'''简单绘制sin和cos规律的散点图'''
x = np.linspace(0,10,100)
# print(x)
y = np.sin(x)
# print(y)
cosy = np.cos(x)
siny = y.copy()
#绘制散点图
plt.scatter(x,siny,marker='o')
plt.scatter(x,cosy,marker='+')
plt.show()
'''绘制正太分布的散点图'''
x = np.random.normal(0,1,1000)
y = np.random.normal(0,1,1000)
#alpha为不透明度
plt.scatter(x,y,alpha=0.5)
plt.show()