1. 程式人生 > >python函式影象繪製

python函式影象繪製

1、實現

import matplotlib.pyplot as plt
import math
import numpy as np

plt.figure(1)

x=[]
y=[]

a=np.linspace(0,10,100)
for i in a:
    x.append(i)
    y.append(10 * math.sin(5 * i) + 7 * math.cos(4 * i))

plt.plot(x,y)

plt.show()