From: gary r. <gr...@bi...> - 2003-10-31 14:29:04
|
Hi John, I've implemented xerrorbars and xyerrorbars commands. I did this by adding two extra functions to the matplot.py rev 1.25 Your code makes it trivial. As matlab seems not to have x or xy-errorbars, I took my inspiration from Gnuplot when deciding whether to implement the different versions as separate commands or as different formats of parameters to errorbars command. However, since I haven't discussed this with you and just went ahead and did it, I'll just provide the diffs here (and email you the matplot.py file offlist to save you patching it). Also, the xyerrorbars function just naively wraps the errorbars and xerrorbars functions. This means that the plot symbol is rendered twice for each point which is probably not ideal. If you see this as a problem, I can redo it - let me know. On the same topic, I see you just changed the bar end size ratio from 0.005 to 0.001. The bar ends are now quite small and I don't think 0.005 was excessive, so I'd be inclined to revert it back although I guess you had a reason. Gnuplot makes the bar end size a settable parameter which would be a better solution IMHO. regards, Gary ---8<---Cut here---8<--- 185a186,187 > xerrorbar - make an errorbar graph (errors along x-axis) > xyerrorbar - make an errorbar graph (errors along both axes ) 195c197 < 'figure', 'gca', 'gcf', 'close' ] --- > 'figure', 'gca', 'gcf', 'close', 'xerrorbar', 'xyerrorbar' ] 372c374,407 < def errorbar(x, y, e, u=None, fmt='b-'): --- > > > def xyerrorbar(x, y, e, f, u=None, v=None, fmt='b-'): > """ > Plot x versus y with x-error bars in e and y-error bars in f. > If u is not None, then u gives the upper x-error bars and e gives the lower > x-error bars. > Otherwise the error bars are symmetric about y and given in the array e. > If v is not None, then v gives the upper y-error bars and f gives the lower > y-error bars. > Otherwise the error bars are symmetric about x and given in the array f. > > fmt is the plot format symbol for the x,y point > > Return value is a length 2 tuple. The first element is a list of > y symbol lines. The second element is a list of error bar lines. > > """ > errorbar(x, y, e, u, fmt) > xerrorbar(x, y, f, v, fmt) > > > def xerrorbar(x, y, e, u=None, fmt='b-'): > """ > Plot x versus y with error bars in e. if u is not None, then u > gives the left error bars and e gives the right error bars. > Otherwise the error bars are symmetric about x and given in the > array e. > > fmt is the plot format symbol for y > > Return value is a length 2 tuple. The first element is a list of > y symbol lines. The second element is a list of error bar lines. > 373a409,432 > l0 = plot(x,y,fmt) > > e = asarray(e) > if u is None: u = e > right = x+u > left = x-e > height = (max(y)-min(y))*0.001 > a = gca() > try: > l1 = a.hlines(y, x, left) > l2 = a.hlines(y, x, right) > l3 = a.vlines(right, y-height, y+height) > l4 = a.vlines(left, y-height, y+height) > except ValueError, msg: > msg = raise_msg_to_str(msg) > error_msg(msg) > raise RuntimeError, msg > > l1.extend(l2) > l3.extend(l4) > l1.extend(l3) > draw_if_interactive() > return (l0, l1) > 374a434,435 > def errorbar(x, y, e, u=None, fmt='b-'): > """ |