如何在这段代码中为四条曲线之间的区域填充颜色?其中两条曲线是两个点之间的连接。我尝试了以下脚本。倒数第二行是错误的。
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.patches as patches
x_shift = 140.5
b = 50
const = 28.3
fig, ax = plt.subplots()
plt.rcParams["figure.figsize"] = [10, 3]
r = np.sqrt(36000)
theta_zoom1 = np.linspace(-0.14*np.pi, 0, 10000)
x1_zoom1 = r*np.cos(theta_zoom1) - x_shift
x2_zoom1 = r*np.sin(theta_zoom1) + b
theta_zoom2 = np.linspace(-0.156*np.pi, 0, 10000)
x1_zoom2 = r*np.cos(theta_zoom2) - x_shift
x2_zoom2 = r*np.sin(theta_zoom2) + b
ax.plot(x1_zoom1 + const, x2_zoom1)
ax.plot(x1_zoom2 + 3*const, x2_zoom2)
plt.plot([60, 130],[-9.2, -9.2])
plt.plot([70, 140],[35.7, 35.7])
ax.fill_between(x2_zoom1, x2_zoom2)
plt.show()
错误结果:
fill_between
。我用平行四边形作为例子可以吗? - Mad Physicist