import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0, 10, 100)
siny = np.sin(x)
cosy = np.cos(x)
#---绘图---
plt.plot(x, siny, label="sin x")
plt.plot(x, cosy, color="red", linestyle="--", label="cos x")
#---轴的范围---
# plt.xlim(-5, 15)
# plt.ylim(-1.5, 1.5)
plt.axis([-5, 15, -1.5, 1.5])
#---轴的标签---
plt.xlabel("x_axis")
plt.ylabel("y_axis")
#---渲染出曲线label属性的内容---
plt.legend()
plt.title("Title!!!!")
plt.show()
plt.scatter(x, siny, label="sin x")
plt.scatter(x, cosy, color="red", label="cos x")
plt.axis([-5, 15, -1.5, 1.5])
plt.legend()
plt.show()
# 二维正态分布
x = np.random.normal(0, 1, 10000)
y = np.random.normal(0, 1, 10000)
plt.scatter(x, y, alpha=0.1) #alpha:透明度
plt.show()
因篇幅问题不能全部显示,请点此查看更多更全内容
Copyright © 2019- azee.cn 版权所有 赣ICP备2024042794号-5
违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务