我正在尝试基于两个垂直坐标创建一个阴影矩形(矩形的长度应跨越整个 x 轴)。
我尝试将 fill_ Between
与以下内容一起使用(p1 和 p2 是数据坐标):
f, ax1 = plt.subplots()
x = np.linspace(200,300,2000)
y = x**(2)
y1 = x
p1 = 4700
p2 = 7700
ax1.plot(x, y, lw=2)
ax1.set_xlabel('Temperature $[K]$', fontweight='bold')
ax1.set_ylabel('Pressure $[mb]$', fontweight='bold')
ax1.fill_between(x, y1.fill(p1), y1.fill(p2))
但我收到以下错误:
TypeError: ufunc 'isfinite' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
出了什么问题?有更好的方法吗?
谢谢!!
最佳答案
关于python - matplotlib中2个y坐标之间的阴影区域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50646523/