在pandas中绘制fill_between

时间:2017-12-01 17:11:10

标签: python pandas matplotlib plot

我的df:

    1994-02-04  1997-03-25  1999-06-30  2004-06-30  2015-12-17  mean    min max
-20 -0.131310   -0.942392   -1.068188   -0.298004   -1.116645   -0.711308   -1.11664    -0.13131
-19 -0.072950   -0.653595   -1.009658   -0.398474   -0.561465   -0.539228   -1.00966    -0.0729501
-18 0.014590    -0.668795   -1.214516   -0.602820   -0.265169   -0.547342   -1.21452    0.01459
-17 -0.554421   -0.683995   -0.804800   -0.904230   -0.191844   -0.627858   -0.90423    -0.191844
-16 -0.175080   -0.075999   -1.653497   -0.650501   -0.241226   -0.559261   -1.6535 -0.0759994
-15 0.014590    0.273598    -1.521803   0.214563    -0.108043   -0.225419   -1.5218 0.273598
-14 0.000000    0.273598    -1.682763   -0.570465   0.228656    -0.350195   -1.68276    0.273598

我想绘制平均值,最小值和最大值,其中最小值和最大值之间的区域用阴影表示。我正在尝试......:

ax = df.plot(y=['min'],figsize=(12,8))
df['max'].plot(ax=ax)
df['mean'].plot(ax=ax)   

ax.fill_between(df.index,df['max'],df['min'])

这给了我一张没有阴影和错误的图表:

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''

你知道哪里出错了吗?

0 个答案:

没有答案