Error Bar Python Fmt
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this http://stackoverflow.com/questions/11774822/matplotlib-histogram-with-errorbars site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss https://mail.python.org/pipermail/tutor/2015-August/106242.html Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Matplotlib histogram with error bar errorbars up vote 7 down vote favorite 2 I have created a histogram with matplotlib using the pyplot.hist() function. I would like to add a Poison error square root of bin height (sqrt(binheight)) to the bars. How can I do this? The return tuple of .hist() includes return[2] -> a list of 1 Patch objects. I could only find out that it is possible error bar python to add errors to bars created via pyplot.bar(). matplotlib histogram share|improve this question edited Jan 19 at 8:09 Pardeep Dhingra 2,38651539 asked Aug 2 '12 at 9:39 bioslime 4131817 add a comment| 2 Answers 2 active oldest votes up vote 6 down vote accepted Indeed you need to use bar. You can use to output of hist and plot it as a bar: import numpy as np import pylab as plt data = np.array(np.random.rand(1000)) y,binEdges = np.histogram(data,bins=10) bincenters = 0.5*(binEdges[1:]+binEdges[:-1]) menStd = np.sqrt(y) width = 0.05 plt.bar(bincenters, y, width=width, color='r', yerr=menStd) plt.show() share|improve this answer edited Feb 14 at 11:11 bastelflp 1,4311629 answered Aug 2 '12 at 10:37 imsc 3,1491740 Awesome, that solves it. Thanks. –bioslime Aug 2 '12 at 10:50 add a comment| up vote 3 down vote Alternative Solution You can also use a combination of pyplot.errorbar() and drawstyle keyword argument. The code below creates a plot of the histogram using a stepped line plot. There is a marker in the center of each bin and each bin has the requisite Poisson errorbar. import numpy import pyplot x = numpy.random.rand(1000) y, bin_edges = numpy.histogram(x, bins=10) bin_centers = 0.5*(bi
message (by thread): [Tutor] About Python Module to Process Bytes Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] Colin Ross wrote: > Hi all, > > Goal: To plot asymmetric x error bars for a single point using errorbar. I > am interested in displaying the inter quartile range (IQR) for a data set. > > Code: > > import numpy as np > import matplotlib.pyplot as plt > > y = 1.0 > data = np.random.rand(100) > > median = np.median(data) > upper_quartile = np.percentile(data, 75) > lower_quartile = np.percentile(data, 25) > IQR = upper_quartile - lower_quartile > > plt.errorbar(median, y, xerr=[lower_quartile ,upper_quartile], fmt='k--') > > plt.savefig('IQR.eps') > plt.show() > > Error: > > Traceback (most recent call last): > File "IQR.py", line 15, in