1
我知道有a very related question here。然而,那裏的解決方案適用於這個例子,但它仍然給我一個錯誤。如何將錯誤欄添加到使用python熊貓的分組條形圖?
這是我非常簡單的代碼:
我試圖誤差線添加到我的分組條形圖。
df = pd.DataFrame([[ 1306, 5148, 1729, 1377, 1051, 179, 7250],
[ 2202, 8445, 2749, 1573, 1898, 292, 11466],
[ 46, 281, 71, 53, 35, 4, 293],
[ 445, 1701, 553, 470, 355, 53, 3088],
[ 145, 583, 190, 100, 138, 16, 1505],
[ 164, 476, 164, 72, 188, 12, 1311],
[ 174, 842, 254, 129, 177, 34, 2599]])
df.columns = ['A', 'B', 'C', 'D', 'E', 'F', 'G']
df.index = ['a', 'b', 'c', 'd', 'e', 'f', 'g']
yerr = array([[ 0.00192938, 0.001575 , 0.00840369, 0.00305756, 0.00437465,
0.00517742, 0.00306851],
[ 0.00336221, 0.00269552, 0.01714203, 0.00534033, 0.00797719,
0.00817815, 0.00616608],
[ 0.00219171, 0.00174148, 0.01026187, 0.00337873, 0.00496298,
0.00517742, 0.00367047],
[ 0.00197692, 0.00134693, 0.00897753, 0.00313595, 0.00366509,
0.00350077, 0.00265679],
[ 0.00174394, 0.00147064, 0.00738486, 0.00275061, 0.00427364,
0.00551332, 0.0030937 ],
[ 0.00073795, 0.00059391, 0.00254775, 0.00108794, 0.00148974,
0.00144758, 0.00137975],
[ 0.00365027, 0.00289623, 0.01729375, 0.00610798, 0.00958869,
0.01018425, 0.00749114]])
df.plot(kind='bar', yerr=yerr)
給人以
ValueError: too many values to unpack
任何想法,爲什麼?我認爲yerr的形狀與df(它是相同的)
什麼版本?我只是在0.14上運行它,它似乎工作(雖然錯誤欄是如此之小,你不能真正看到它們) – chrisb
是的,酒吧是微小的,因爲它不是我正在繪製的確切的東西。只是一個DF我生成複製。我正在使用.13.1。將嘗試升級並回報 – pocketfullofcheese
是。那工作。謝謝。 – pocketfullofcheese