Asymmetric Error Bars Python
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 site About Us Learn more about Stack Overflow the company Business Learn more about
Asymmetric Error Bars Sigmaplot
hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask matplotlib errorbar no line Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join seaborn error bars them; it only takes a minute: Sign up Upper/lower limits with matplotlib up vote 6 down vote favorite 1 I want to plot some data points with errorbars. Some of these data points have only upper or lower limit, http://matplotlib.org/1.2.1/examples/pylab_examples/errorbar_demo.html instead of error bars. So I was trying to use indices to differentiate between the points with errorbars, and the points with upper/lower limits. However, when I try something like this: errorbar(x[i], y[i], yerr = (ymin[i], ymax[i])) I receive the error: ValueError: In safezip, len(args[0])=1 but len(args[1])=2 This is similar to the discussion here, but I don't use pandas, and however, it would be really useful to me to read some other few words about that. In any http://stackoverflow.com/questions/15621643/upper-lower-limits-with-matplotlib case, I tried to "turnaround" the error in the following way: errorbar(x[i], y[i], yerr = [[ymin[i], ymax[i]]], uplims = True) But the resulting plot is not clear: it seems that the upper limit AND the errorbars are plotted together, or the upper limit is plotted twice... The goal is to plot upper/lower limits when the upper and lower error bars are not symmetrical, so I can choose the length of the bar before the arrow for the upper/lower limit. python matplotlib share|improve this question asked Mar 25 '13 at 18:02 Py-ser 334622 add a comment| 1 Answer 1 active oldest votes up vote 4 down vote This is actually one of the things that tends to annoy me about errorbar: it's very finicky about the shape and dimensionality of inputs. What I'm assuming is that you want "error bars", but want their locations to be set by absolute upper and lower bounds, rather than by a symmetric "error" value. What errorbar does is zip together (with safezip) your y array and yerr[0] for the lower bound (yerr[1] for upper). So your y and yerr[0] (and [1]) should be arrays with the same size, shape and number of dimensions. yerr itself doesn't need to be an array at all. The first code that you have will work if x, y, ymin, and ymax are all one-dimensional arrays, which is what they should be. It
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 site About Us http://stackoverflow.com/questions/17580556/asymmetric-error-bars-in-matplotlib Learn more about Stack Overflow the company Business Learn more about hiring developers https://mail.python.org/pipermail/tutor/2015-August/106242.html or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss 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 Asymmetric Error Bars in MatPlotLib up vote error bars 2 down vote favorite I have a loglog plot and would like to plot positive error bar for one of the 6 data points. The rest can have positive & negative. How do I work this out? Generally this is how I have plotted error bars: plt.loglog(vsini_rand, vsini_rand_lit, 'bo', label='Randich+1996') plt.errorbar(vsini_rand, vsini_rand_lit, xerr = sig_rand, color = 'gray', fmt='.', zorder=1) plt.loglog(x,y,'r-', zorder=3, label='1:1') python matplotlib share|improve this asymmetric error bars question edited Jul 10 '13 at 20:53 sonne 189318 asked Jul 10 '13 at 20:46 Rohit 92131531 1 See the docs: matplotlib.org/api/axes_api.html#matplotlib.axes.Axes.errorbar –tacaswell Jul 10 '13 at 22:19 add a comment| 1 Answer 1 active oldest votes up vote 1 down vote Reading the documentation of plt.errorbar, if you want to plot assymmetric errorbars you have to use as argument of xerr a sequence of shape 2xN. If you do so, errorbars are drawn at -row1 and +row2 relative to the data. If you want to plot a positive error bar for only one point, you should define to zero the lower limit. I mean, if your data is: [x1, x2, ... , xn] you have to give the sequence: [x0-,x0+,x1-,x1+, ... , xn-,xn+] as argument of xerr. Hope it helps. share|improve this answer answered Jul 12 '13 at 21:42 Alejandro 916522 add a comment| Your Answer draft saved draft discarded Sign up or log in Sign up using Google Sign up using Facebook Sign up using Email and Password Post as a guest Name Email Post as a guest Name Email discard By posting your answer, you agree to the privacy policy and terms of service.
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