python图标绘制基础:matplotlib

import numpy as np
import matplotlib.pyplot as plt

x = np.linspace(0, 10, 1000) #作图的自变量0~10,中间1000个单位
y = np.sin(x) + 1
z = np.cos(x ** 2) + 1

plt.figure(num = 2, figsize=(8, 4))   #图像编号,设置图像大小
plt.plot(x, y, color = "red", label = '$\sin x + 1$', linewidth = 2) #画图
plt.plot(x, z,linestyle = '--', label = '$\cos x**2 + 1$') #linestyle设置样式
plt.xlabel("Times(s)")
plt.ylabel("Volt")
plt.title("A sample Example")
plt.ylim(0, 2,2)    #显示y轴范围
plt.legend() #显示图例
plt.show() #显示作图结果

这里写图片描述

猜你喜欢

转载自blog.csdn.net/weixin_36372879/article/details/80786979