import matplotlib.pyplot as plt
import numpy as np
def domain():
x = np.arange(0, 10, 0.001)
f1 = lambda x: (2*x - x**2)**0.5
plt.plot(x, f1(x), label = '$y = \sqrt{2x - x^2}$')
plt.plot(f1(x), x, label = '$x = \sqrt{2y - y^2}$')
plt.xlabel('X')
plt.ylabel('Y')
plt.legend(loc='best')
axes = plt.gca()
axes.set_xlim([0, 5])
axes.set_ylim([0, 5])
plt.show()
domain()
如何使用 fill_between()
填充两条线之间的区域?换句话说,如何填充绿色和蓝色线之间的小花瓣?
0<x<1
,表达式1 + (1-x*x)**0.5
总是>1
,因此推导使用1 - (1-x*x)**0.5
。 - Zero