【发布时间】:2018-06-01 15:15:42
【问题描述】:
我正在尝试基于两个垂直坐标创建一个阴影矩形(矩形的长度应该跨越整个 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''
怎么了?有更好的方法吗?
谢谢!!
【问题讨论】:
-
y1.fill(p1)不返回数组!
标签: python matplotlib