From: John H. <jdh...@ac...> - 2004-12-27 18:57:52
|
>>>>> "Istvan" == Istvan Szapudi <szapudi@IfA.Hawaii.Edu> writes: Istvan> Hi All, I am fairly new to matplotlib, and I am impressed Istvan> with its capabilities. Istvan> I have trouble plotting loglog plots with errorbars. I Istvan> have the following, program, a slightly modified version Istvan> of one given earlier by JDH on 9-28-2004 in this mailing Istvan> list: This is definitely a gotcha that matplotlib needs to be smarted about handling. The log zero error is occurring when the transformation is made on the axes limits and not on the data. The autoscaler picks the best min/max for the data coordinates, and will round down or up to facilitate nice integer ticking. When you plot with linear coords, the autoscaler makes it's pick according to linear scaling, and then when you change scales the old scaling is in effect and the log transform fails when converting the viewport. Solution: rescale the axes after changing coords, either manually ax.set_yscale("log") ax.set_xscale("log") axis([0.5*min(x), 2*max(x), 0.5*min(y-err), 2*max(y+err)]) or use the autoscaler ax.set_yscale("log") ax.set_xscale("log") ax.autoscale_view() or set your log coords *before* calling plot ax = gca() ax.set_yscale("log") ax.set_xscale("log") errorbar(x,y,err,fmt='o') show() and then the errorbar command will pick a "locator" to handle ticking and viewport scaling appropriately from the outset. This is the approach taken in http://matplotlib.sf.net/examples/log_bar.py . Until I get this fixed to work automagically, I'll make it a FAQ. JDH |