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",color = "green")
plt.plot(x,y2, linestyle = "-.", label = "cos")
#linestyle参数:'-', '--', '-.', ':', 'None', ' ', '', 'solid', 'dashed', 'dashdot', 'dotted'
plt.xlabel("x")#横轴坐标名
plt.ylabel("y")#纵轴坐标名
plt.title("sin & cos")#图表标题
plt.legend()# 显示label
plt.show()
#读入图像
import matplotlib.pyplot as plt
from matplotlib.image import imread
img = imread('C:\\Users\\Coco1522\\Desktop\\lena.jpg')#设定合适的路径
plt.imshow(img)
plt.show()