import matplotlib.mlab as mlab
import matplotlib.pyplot as plt
import numpy as np
x = np.arange(0.0, 2, 0.01)
y1 = np.sin(2*np.pi*x)
y2 = np.cos(2*np.pi*x)
fig, ax = plt.subplots()
ax.plot(x, y1, x, y2, color='black')
ax.fill_between(x, y1, y2, where=y2>y1, facecolor='green')
ax.fill_between(x, y1, y2, where=y2<=y1, facecolor='red')
ax.set_title('Fill between where')
plt.show()
# Fill between y=sin(2pi x) and y=cos(2pi x)
# Lissajous' figures
# Lissajous' figures
# python code is as follows:
import numpy as np
import matplotlib.pyplot as plt
a=1
b=1
p=9
q=10
c=0.0
t = np.linspace(0,6.28, 1000)
x = a*np.sin(p*t)
y= b*np.cos(q*t+c)
plt.figure(figsize=(8,6))
plt.plot(x,y,color="red",linewidth=2)
plt.title("Lissajous' figures")
plt.show()
# The output is as follows:
訂閱:
文章 (Atom)