plot() – draw a graph
No video link yet
Function format:
plt.plot(x,y,ls="-",lw=2,label="图例名")
Parameter Description:
- x: the value on the x-axis
- y: the value on the y-axis
- ls: line style
- lw: line width
- label: legend text
code:
import matplotlib.pyplot as plt
import numpy as np
# 准备数据
x = np.linspace(0.05,10,100)
y = np.sin(x)
# 画线条
plt.plot(x,y,ls=":",label="plot")
# 显示图例
plt.legend()
# 显示图形,必须的
plt.show()