我正在构建一个带有pandas和matplotlib的条形图。我需要错误栏,但我的功能不会创建它们,我收到以下消息:
C:\Python27\lib\site-packages\matplotlib\collections.py:590: FutureWarning: elementwise comparison failed; returning sca
lar instead, but in the future will perform elementwise comparison
if self._edgecolors == str('face'):
根据大熊猫密谋文件:
The error values can be specified using a variety of formats.
As a DataFrame or dict of errors with column names matching the columns attribute of the plotting DataFrame or matching the name attribute of the Series
As a str indicating which of the columns of plotting DataFrame contain the error values
As raw values (list, tuple, or np.ndarray). Must be the same length as the plotting
我有以下内容:
recsFrame_mean = recsFrame.groupby('REGIONC').mean()
recsFrame_mean.plot(y='weighted_KWH',yerr='se_KWH', kind='bar')
recsFrame_mean具有以下结构:
>>> print(recsFrame_mean)
DIVISION REPORTABLE_DOMAIN TYPEHUQ NWEIGHT HDD65 \
REGIONC
1 1.586055 2.734775 2.997793 9166.128420 5894.129303
2 3.595498 9.556806 2.476609 9116.257475 6285.651425
3 5.751589 17.612958 2.558924 10288.546455 2436.917604
4 9.564147 25.390777 2.717060 8615.848474 3067.628294
... PERIODLP SCALELP PERIODFO SCALEFO PERIODKR \
REGIONC ...
1 ... -1.536187 -1.684025 -0.392763 -0.897617 -1.854810
2 ... -1.523039 -1.676750 -1.906437 -1.934576 -1.945480
3 ... -1.528117 -1.679951 -1.945477 -1.963325 -1.951100
4 ... -1.650485 -1.758322 -1.971221 -1.980583 -1.968793
SCALEKER NGHSQFT ELECHSQFT weighted_KWH se_KWH
REGIONC
1 -1.897617 0.402426 5.895109 7.407772e+07 7923.790058
2 -1.962715 0.405440 7.297165 9.647961e+07 11282.706985
3 -1.966259 0.138032 10.506909 1.498108e+08 14699.751866
4 -1.978155 0.299447 7.095108 8.017829e+07 8982.045134
[4 rows x 931 columns]
答案 0 :(得分:2)
我有时会通过大熊猫绘制误差棒的问题。试试yerr=list(recsFrame_mean['se_KWH'])
因为我认为这对我来说是一贯的工作方法。