matplotlib:带有错误栏的plot_date图

时间:2019-11-10 22:10:53

标签: python matplotlib

如果我有数据框tmp

      TripDate  Norm_Area  Norm_Vol  std_error
0   1990-06-10   1.255452  0.533595   0.135439
1   1991-07-26   1.378561  0.568246   0.108837
2   1992-10-15   1.145503  0.368524   0.100697
3   1993-10-08   1.068357  0.299930   0.063017
4   1994-04-07   1.162902  0.224679   0.032259
5   1994-11-20   1.041273  0.308833   0.079594
6   1995-04-24   1.072607  0.184373   0.032172
7   1996-02-13   1.081897  0.172615   0.026566
8   1996-04-15   1.307461  0.355679   0.068596
9   1996-09-12   1.115854  0.257848   0.049068
10  1997-02-13   1.104726  0.251816   0.055927
11  1997-04-20   1.250355  0.262875   0.058467
12  1997-08-23   1.228685  0.240228   0.061329
13  1997-11-06   1.003719  0.458671   0.098366
14  1998-04-15   1.185031  0.207117   0.040564
15  1999-05-04   1.106653  0.159329   0.022966
16  2000-03-17   1.237591  0.193796   0.014618
17  2000-06-01   1.156435  0.259144   0.038385
18  2001-10-05   1.044858  0.324644   0.059274
19  2002-09-20   1.031219  0.277862   0.042626
20  2003-04-25   1.083108  0.308298   0.046870
21  2003-09-20   1.046919  0.295158   0.050972
22  2005-05-07   1.288566  0.589510   0.069558
23  2006-10-07   1.009837  0.368267   0.047479
24  2007-10-13   1.141893  0.385878   0.074138
25  2008-02-02   1.239919  0.238118   0.041671
26  2008-03-28   1.302795  0.414753   0.074729
27  2008-10-10   1.124744  0.447796   0.068569
28  2009-10-10   1.145686  0.394291   0.050279
29  2011-10-05   1.046638  0.385551   0.089998
30  2012-10-03   1.216645  0.329890   0.063171
31  2013-09-21   1.189586  0.470421   0.085163
32  2014-09-23   1.180354  0.495900   0.074334
33  2015-09-22   1.249672  0.435109   0.077877
34  2016-10-01   1.136692  0.386011   0.091367
35  2017-09-29   1.214943  0.437834   0.088760
36  2018-09-25   1.210593  0.452112   0.093586

我以前使用以下方法绘制数据:

tmp.plot(x='TripDate',y='Norm_Vol', yerr='std_error')

但是我现在知道,当您需要格式化日期时,使用熊猫来绘制日期会造成混乱。如果我想使用plt.plot_date,如何在绘图中添加y误差线?

plt.plot_date('TripDate','Norm_Vol',data = tmp)

谢谢。

0 个答案:

没有答案