美文网首页
matplotlab初体验

matplotlab初体验

作者: 东方未白_ | 来源:发表于2019-08-12 10:27 被阅读0次
import numpy as np
import matplotlib.pyplot as plt
# 生成数据
x = np.arange(0, 6, 0.1) # 以0.1为单位,生成0到6的数据
y1 = np.sin(x)
y2 = np.cos(x)
# 绘制图形
plt.plot(x, y1, label="sin")
plt.plot(x, y2, linestyle = "--", label="cos") # 用虚线绘制
plt.xlabel("x") # x轴标签
plt.ylabel("y") # y轴标签
plt.title('sin & cos') # 标题
plt.legend()
plt.show()

sin-cos

相关文章

网友评论

      本文标题:matplotlab初体验

      本文链接:https://www.haomeiwen.com/subject/eoeyjctx.html