matplotib 课堂练习-第8周

import matplotlib.pyplot as plt
import numpy as np
names = ['2017','2018','2019']
values= [10,35,75]
plt.figure()
plt.subplot(1,3,1)
plt.bar(names,values)
plt.subplot(1,3,2)
plt.scatter(names,values)
plt.subplot(1,3,3)
plt.plot(names,values)

  

 

 

import matplotlib.pyplot as plt
import numpy as np
def func(t):
    return np.exp(-t)*np.cos(2*np.pi*t)
x1 = np.arange(0.0,5.0,0.1)
x2 = np.arange(0.0,5.0,0.02)
plt.figure()
plt.subplot(2,1,1)
y1 = func(x1)
plt.scatter(x1,y1)
y2 = func(x2)
plt.plot(x1,y1)

plt.subplot(2,1,2)
plt.plot(x2,y2,'r--')

  

 

posted on 2019-10-23 13:35  robot9  阅读(108)  评论(0编辑  收藏  举报

导航