matplotlib 练习题.
11.1:
代码:
#! usr/bin/python
# -*- coding: UTF-8 -*-
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0, 2, 1000)
y = np.power(np.sin(x - 2) , 2) * np.power(np.e, np.power(x, 2) * -1)
plt.plot(x, y)
plt.xlabel('x')
plt.ylabel('y')
plt.title(r"$sin^2(x-2)e^{-x^2}$")
plt.show()
运行结果:
11.2:
代码:
#! usr/bin/python
# -*- coding: UTF-8 -*-
import matplotlib.pyplot as plt
import numpy as np
X = np.random.randn(20,10)
b &