Python3学习-Matplotlib(1)
Matplotlib安装
dos命令下----运行:Python -m pip install matplotlib
安装后:测试代码:
import matplotlib as plt
import numpy as np
x = np.linspace(1, 50)
y = 2*x + 1
plt.plot(x, y)
plt.show()
显示:
figure图像
import matplotlib as plt
import numpy as np
x = np.linspace(-1, 1, 50)
y1 = 2*x + 1
y2 = x**2
plt.figure()
plt.plot(x, y1)
plt.figure()
plt.plot(x, y2)
plt.show()
效果:
修改figuer名:
plt.figure(num = 6)
效果:
修改figuer尺寸:
plt.figure(num = 6, figsize=(5, 4))
效果:
使figuer多数据:
plt.figure(num = 6, figsize=(5, 4))
plt.plot(x, y2)
plt.plot(x, y1)
效果:
修改线条参数:
color-颜色 linewidth-宽度 linestyle-线条风格
plt.plot(x, y1, color = 'red', linewidth = 1.0, linestyle = '--' )
效果: