52-python 画图二维

Python--matplotlib绘图可视化知识点整理

1.折线图:

import numpy as np
import matplotlib.pyplot as plt
from pylab import *

x = np.arange(1.,2.,0.2)  # 1到2,间隔0.2
y1 = np.arange(1.,2.,0.2)

plt.figure(1)      # 画一张图
plt.subplot(311)   # 3行一列
plt.plot(x, y1,'r*')

plt.subplot(312)
plt.figure(1)
plt.plot([1,2,3,4], [1,2,2,4],'bo')

plt.subplot(313)
# evenly sampled time at 200ms intervals
t = np.arange(0., 5., 0.2)
# red dashes, blue squares and green triangles
plt.plot(t, t, 'r--', t, t**2, 'bs', t, t**3, 'g^')

plt.show()  # 显示图片

  

猜你喜欢

转载自www.cnblogs.com/zhumengdexiaobai/p/10720879.html