barra de matplotlib con barras de error asimétricas
Necesito trazar un gráfico de barras con barras de error asimétricas ...
La documentación de la función matplotlib.pyplot.bar dice:
Detalle: xerr y yerr se pasan directamente a la barra de errores (), por lo que también pueden tener la forma 2xN para la especificación independiente de errores inferiores y superiores.
Pero, no puedo dar una matriz 2xN al yerr ...
import numpy as np
import matplotlib.pyplot as plt
plt.bar(xrange(5), [2,5,3,4,7], yerr=[[1,4,2,3,6],[4,10,6,8,14]]) #DO NOT work!
Y enséñame el siguiente error:
Traceback (most recent call last):
File "bar_stacked.py", line 9, in <module>
plt.bar(xrange(5), [2,5,3,4,7], yerr=[[1,4,2,3,6],[4,10,6,8,14]])
File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 1742, in bar
ret = ax.bar(left, height, width, bottom, color, edgecolor, linewidth, yerr, xerr, ecolor, capsize, align, orientation, log, **kwargs)
File "/usr/lib/pymodules/python2.7/matplotlib/axes.py", line 4253, in bar
"incompatible sizes: bar() argument 'yerr' must be len(%s) or scalar" % nbars)
ValueError: incompatible sizes: bar() argument 'yerr' must be len(5) or scalar
Pero, en cambio, esta función:
import numpy as np
import matplotlib.pyplot as plt
plt.errorbar(xrange(5), [2,5,3,4,7], yerr=[[1,4,2,3,6],[4,10,6,8,14]])
Funciona bien.
¿Matplotlib.pyplot.bar ya no admite las matrices 2xN para yerr? Si la respuesta es sí ... ¿Cómo puedo trazar un gráfico de barras con barras de error asimétricas?
¡Gracias por tu tiempo!