相关疑难解决方法(0)

Pandas和Matplotlib - fill_between()vs datetime64

有一个Pandas DataFrame:

<class 'pandas.core.frame.DataFrame'>
Int64Index: 300 entries, 5220 to 5519
Data columns (total 3 columns):
Date             300 non-null datetime64[ns]
A                300 non-null float64
B                300 non-null float64
dtypes: datetime64[ns](1), float64(2)
memory usage: 30.5 KB
Run Code Online (Sandbox Code Playgroud)

我想绘制A和B系列与日期的关系.

plt.plot_date(data['Date'], data['A'], '-')
plt.plot_date(data['Date'], data['B'], '-')
Run Code Online (Sandbox Code Playgroud)

然后我想在A和B系列之间的区域上应用fill_between():

plt.fill_between(data['Date'], data['A'], data['B'],
                where=data['A'] >= data['B'],
                facecolor='green', alpha=0.2, interpolate=True)
Run Code Online (Sandbox Code Playgroud)

哪个输出:

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''
Run Code Online (Sandbox Code Playgroud)

matplotlib是否在 …

python matplotlib pandas

34
推荐指数
2
解决办法
1万
查看次数

标签 统计

matplotlib ×1

pandas ×1

python ×1