From: CohenTanugi Johann <johann.cohentanugi@gm...>  20090327 15:16:11

Hello, what is the best way to get log log plots with error bars? I tried putting log10() everywhere but as I was afraid results look ugly.... thanks, johann 
From: Matthias Michler <MatthiasM<ichler@gm...>  20090331 11:10:50
Attachments:
errobar_with_log_log_scaling.png

Hello Johann, is the problem you are reporting the one I observe in the attached picture? Namely some vertical and horizontal lines are missing when using yscale="log". More precisely everything below y=1 seems to be missing. The picture was generated with the code below and matplotlib.__version__ = '0.98.6svn' matplotlib.__revision__ = '$Revision: 6887 $' best regards Matthias ############################### import numpy as np import matplotlib.pyplot as plt plt.subplot(111, xscale="log", yscale="log") x = 10.0**np.linspace(0.0, 2.0, 20) y = x**2.0 plt.errorbar(x, y, xerr=0.1*x, yerr=5.0+0.75*y) plt.show() ################################ On Friday 27 March 2009 16:12:12 CohenTanugi Johann wrote: > Hello, what is the best way to get log log plots with error bars? I > tried putting log10() everywhere but as I was afraid results look ugly.... > thanks, > johann 
From: CohenTanugi Johann <cohen@lp...>  20090331 12:07:16

yes exactly.... I should have provided a test case, thanks for following up! Johann Matthias Michler wrote: > Hello Johann, > > is the problem you are reporting the one I observe in the attached picture? > Namely some vertical and horizontal lines are missing when using > yscale="log". More precisely everything below y=1 seems to be missing. > > The picture was generated with the code below and > matplotlib.__version__ = '0.98.6svn' > matplotlib.__revision__ = '$Revision: 6887 $' > > best regards Matthias > > ############################### > import numpy as np > import matplotlib.pyplot as plt > > plt.subplot(111, xscale="log", yscale="log") > x = 10.0**np.linspace(0.0, 2.0, 20) > y = x**2.0 > plt.errorbar(x, y, xerr=0.1*x, yerr=5.0+0.75*y) > plt.show() > ################################ > On Friday 27 March 2009 16:12:12 CohenTanugi Johann wrote: > >> Hello, what is the best way to get log log plots with error bars? I >> tried putting log10() everywhere but as I was afraid results look ugly.... >> thanks, >> johann >> >> >>  >> >>  >> >>  >> >>  >> >> _______________________________________________ >> Matplotlibusers mailing list >> Matplotlibusers@... >> https://lists.sourceforge.net/lists/listinfo/matplotlibusers >> 
From: Michael Droettboom <mdroe@st...>  20090331 15:09:35

I have to say I don't really have a lot of experience with error bars on log plots  but the root cause here is that the lower bound of the error bar goes negative, and as we all know, the log of a negative number is undefined. If you can suggest where the lower bound should be drawn or provide thirdparty examples, I'm happy to look into this further and resolve this "surprise". Mike CohenTanugi Johann wrote: > yes exactly.... > I should have provided a test case, thanks for following up! > Johann > > Matthias Michler wrote: > >> Hello Johann, >> >> is the problem you are reporting the one I observe in the attached picture? >> Namely some vertical and horizontal lines are missing when using >> yscale="log". More precisely everything below y=1 seems to be missing. >> >> The picture was generated with the code below and >> matplotlib.__version__ = '0.98.6svn' >> matplotlib.__revision__ = '$Revision: 6887 $' >> >> best regards Matthias >> >> ############################### >> import numpy as np >> import matplotlib.pyplot as plt >> >> plt.subplot(111, xscale="log", yscale="log") >> x = 10.0**np.linspace(0.0, 2.0, 20) >> y = x**2.0 >> plt.errorbar(x, y, xerr=0.1*x, yerr=5.0+0.75*y) >> plt.show() >> ################################ >> On Friday 27 March 2009 16:12:12 CohenTanugi Johann wrote: >> >> >>> Hello, what is the best way to get log log plots with error bars? I >>> tried putting log10() everywhere but as I was afraid results look ugly.... >>> thanks, >>> johann >>> >>> >>>  >>> >>>  >>> >>>  >>> >>>  >>> >>> _______________________________________________ >>> Matplotlibusers mailing list >>> Matplotlibusers@... >>> https://lists.sourceforge.net/lists/listinfo/matplotlibusers >>> >>> > >  > _______________________________________________ > Matplotlibusers mailing list > Matplotlibusers@... > https://lists.sourceforge.net/lists/listinfo/matplotlibusers >  Michael Droettboom Science Software Branch Operations and Engineering Division Space Telescope Science Institute Operated by AURA for NASA 
From: CohenTanugi Johann <cohen@lp...>  20090331 15:29:01

I did not look at the code, but I thought that the errors were automatically recomputed in log scale as delta_Y/Y/log(10) Johann Michael Droettboom wrote: > I have to say I don't really have a lot of experience with error bars > on log plots  but the root cause here is that the lower bound of the > error bar goes negative, and as we all know, the log of a negative > number is undefined. If you can suggest where the lower bound should > be drawn or provide thirdparty examples, I'm happy to look into this > further and resolve this "surprise". > > Mike > > CohenTanugi Johann wrote: >> yes exactly.... >> I should have provided a test case, thanks for following up! >> Johann >> >> Matthias Michler wrote: >> >>> Hello Johann, >>> >>> is the problem you are reporting the one I observe in the attached >>> picture? Namely some vertical and horizontal lines are missing when >>> using yscale="log". More precisely everything below y=1 seems to be >>> missing. >>> >>> The picture was generated with the code below and >>> matplotlib.__version__ = '0.98.6svn' >>> matplotlib.__revision__ = '$Revision: 6887 $' >>> >>> best regards Matthias >>> >>> ############################### >>> import numpy as np >>> import matplotlib.pyplot as plt >>> >>> plt.subplot(111, xscale="log", yscale="log") >>> x = 10.0**np.linspace(0.0, 2.0, 20) >>> y = x**2.0 >>> plt.errorbar(x, y, xerr=0.1*x, yerr=5.0+0.75*y) >>> plt.show() >>> ################################ >>> On Friday 27 March 2009 16:12:12 CohenTanugi Johann wrote: >>> >>>> Hello, what is the best way to get log log plots with error bars? I >>>> tried putting log10() everywhere but as I was afraid results look >>>> ugly.... >>>> thanks, >>>> johann >>>> >>>>  >>>> >>>> >>>>  >>>> >>>> >>>>  >>>> >>>> >>>>  >>>> >>>> >>>> _______________________________________________ >>>> Matplotlibusers mailing list >>>> Matplotlibusers@... >>>> https://lists.sourceforge.net/lists/listinfo/matplotlibusers >>>> >> >>  >> >> _______________________________________________ >> Matplotlibusers mailing list >> Matplotlibusers@... >> https://lists.sourceforge.net/lists/listinfo/matplotlibusers >> > 
From: CohenTanugi Johann <cohen@lp...>  20090404 22:05:38

hello, for the sake of concreteness, here is an example without any limit issues : the python script is attached and the 2 resulting figures as well. The dirst one is drawn using log directly in the arguments, and correctly transforming the yerrors into yerrors/yvalues/log(10). In the second figure, I use the log scaling in x and y. Clearly something goes wrong with plotting the error bars, and the yscale limits also seem ill chosen.... HTH debugging this. I looked again at the code, but I am decidedly lost as to where the error bar plotting occurs, and where it gets modified by the log scale request. Johann CohenTanugi Johann wrote: > hello..... Anyone? I would very much love to see this fixed, and I am > ready to help out, but I do not know how to browse through the code. > Despite the fact that log(errors) should of course not be used, but > rathter errors/values/log(10), Michael's point still remains : values > errors in log scale can be negative, so that the artist should just > draw a bar until the lower limit of the vertical bar. I would say that > this is the standard practice. > Sorry for my previous email beside the point. > Johann > > CohenTanugi Johann wrote: >> I tried to look at the code (axes.py I presume) in order to attempt a >> patch, but it defeated me, I do not have the instructions to >> navigate through this code :) >> Where is the actual transform of the error bars occurring? >> thanks, >> Johann >> >> Michael Droettboom wrote: >> >>> I have to say I don't really have a lot of experience with error >>> bars on log plots  but the root cause here is that the lower bound >>> of the error bar goes negative, and as we all know, the log of a >>> negative number is undefined. If you can suggest where the lower >>> bound should be drawn or provide thirdparty examples, I'm happy to >>> look into this further and resolve this "surprise". >>> >>> Mike >>> >>> CohenTanugi Johann wrote: >>> >>>> yes exactly.... >>>> I should have provided a test case, thanks for following up! >>>> Johann >>>> >>>> Matthias Michler wrote: >>>> >>>> >>>>> Hello Johann, >>>>> >>>>> is the problem you are reporting the one I observe in the attached >>>>> picture? Namely some vertical and horizontal lines are missing >>>>> when using yscale="log". More precisely everything below y=1 seems >>>>> to be missing. >>>>> >>>>> The picture was generated with the code below and >>>>> matplotlib.__version__ = '0.98.6svn' >>>>> matplotlib.__revision__ = '$Revision: 6887 $' >>>>> >>>>> best regards Matthias >>>>> >>>>> ############################### >>>>> import numpy as np >>>>> import matplotlib.pyplot as plt >>>>> >>>>> plt.subplot(111, xscale="log", yscale="log") >>>>> x = 10.0**np.linspace(0.0, 2.0, 20) >>>>> y = x**2.0 >>>>> plt.errorbar(x, y, xerr=0.1*x, yerr=5.0+0.75*y) >>>>> plt.show() >>>>> ################################ >>>>> On Friday 27 March 2009 16:12:12 CohenTanugi Johann wrote: >>>>> >>>>>> Hello, what is the best way to get log log plots with error bars? I >>>>>> tried putting log10() everywhere but as I was afraid results look >>>>>> ugly.... >>>>>> thanks, >>>>>> johann >>>>>> >>>>>>  >>>>>> >>>>>> >>>>>>  >>>>>> >>>>>> >>>>>>  >>>>>> >>>>>> >>>>>>  >>>>>> >>>>>> >>>>>> _______________________________________________ >>>>>> Matplotlibusers mailing list >>>>>> Matplotlibusers@... >>>>>> https://lists.sourceforge.net/lists/listinfo/matplotlibusers >>>>>> >>>>  >>>> >>>> _______________________________________________ >>>> Matplotlibusers mailing list >>>> Matplotlibusers@... >>>> https://lists.sourceforge.net/lists/listinfo/matplotlibusers >>>> >> >>  >> >> _______________________________________________ >> Matplotlibusers mailing list >> Matplotlibusers@... >> https://lists.sourceforge.net/lists/listinfo/matplotlibusers >> 
From: CohenTanugi Johann <cohen@lp...>  20090404 22:20:24

ok, maybe it is in scale.py :) And what I see there confirms my initial fears : the log scale transform applies a log to the argument, which is incorrect for an error..... So first of all, another transform needs to be created so that erry is transformed into erry/y/log(base) where base was 10 in my example. past midnight here.... I will see tomorrow if I find time to try out a patch (not the easiest entry point for starting developer's activities in MPL I am afraid....) Johann CohenTanugi Johann wrote: > hello, > for the sake of concreteness, here is an example without any limit > issues : the python script is attached and the 2 resulting figures as > well. The dirst one is drawn using log directly in the arguments, and > correctly transforming the yerrors into yerrors/yvalues/log(10). > In the second figure, I use the log scaling in x and y. Clearly > something goes wrong with plotting the error bars, and the yscale > limits also seem ill chosen.... > > HTH debugging this. I looked again at the code, but I am decidedly > lost as to where the error bar plotting occurs, and where it gets > modified by the log scale request. > > Johann > > > CohenTanugi Johann wrote: >> hello..... Anyone? I would very much love to see this fixed, and I am >> ready to help out, but I do not know how to browse through the code. >> Despite the fact that log(errors) should of course not be used, but >> rathter errors/values/log(10), Michael's point still remains : >> values errors in log scale can be negative, so that the artist >> should just draw a bar until the lower limit of the vertical bar. I >> would say that this is the standard practice. >> Sorry for my previous email beside the point. >> Johann >> >> CohenTanugi Johann wrote: >>> I tried to look at the code (axes.py I presume) in order to attempt >>> a patch, but it defeated me, I do not have the instructions to >>> navigate through this code :) >>> Where is the actual transform of the error bars occurring? >>> thanks, >>> Johann >>> >>> Michael Droettboom wrote: >>> >>>> I have to say I don't really have a lot of experience with error >>>> bars on log plots  but the root cause here is that the lower >>>> bound of the error bar goes negative, and as we all know, the log >>>> of a negative number is undefined. If you can suggest where the >>>> lower bound should be drawn or provide thirdparty examples, I'm >>>> happy to look into this further and resolve this "surprise". >>>> >>>> Mike >>>> >>>> CohenTanugi Johann wrote: >>>> >>>>> yes exactly.... >>>>> I should have provided a test case, thanks for following up! >>>>> Johann >>>>> >>>>> Matthias Michler wrote: >>>>> >>>>> >>>>>> Hello Johann, >>>>>> >>>>>> is the problem you are reporting the one I observe in the >>>>>> attached picture? Namely some vertical and horizontal lines are >>>>>> missing when using yscale="log". More precisely everything below >>>>>> y=1 seems to be missing. >>>>>> >>>>>> The picture was generated with the code below and >>>>>> matplotlib.__version__ = '0.98.6svn' >>>>>> matplotlib.__revision__ = '$Revision: 6887 $' >>>>>> >>>>>> best regards Matthias >>>>>> >>>>>> ############################### >>>>>> import numpy as np >>>>>> import matplotlib.pyplot as plt >>>>>> >>>>>> plt.subplot(111, xscale="log", yscale="log") >>>>>> x = 10.0**np.linspace(0.0, 2.0, 20) >>>>>> y = x**2.0 >>>>>> plt.errorbar(x, y, xerr=0.1*x, yerr=5.0+0.75*y) >>>>>> plt.show() >>>>>> ################################ >>>>>> On Friday 27 March 2009 16:12:12 CohenTanugi Johann wrote: >>>>>> >>>>>>> Hello, what is the best way to get log log plots with error bars? I >>>>>>> tried putting log10() everywhere but as I was afraid results >>>>>>> look ugly.... >>>>>>> thanks, >>>>>>> johann >>>>>>> >>>>>>>  >>>>>>> >>>>>>> >>>>>>>  >>>>>>> >>>>>>> >>>>>>>  >>>>>>> >>>>>>> >>>>>>>  >>>>>>> >>>>>>> >>>>>>> _______________________________________________ >>>>>>> Matplotlibusers mailing list >>>>>>> Matplotlibusers@... >>>>>>> https://lists.sourceforge.net/lists/listinfo/matplotlibusers >>>>>>> >>>>>  >>>>> >>>>> _______________________________________________ >>>>> Matplotlibusers mailing list >>>>> Matplotlibusers@... >>>>> https://lists.sourceforge.net/lists/listinfo/matplotlibusers >>>>> >>> >>>  >>> >>> _______________________________________________ >>> Matplotlibusers mailing list >>> Matplotlibusers@... >>> https://lists.sourceforge.net/lists/listinfo/matplotlibusers >>> > >  > > >  > >  > >  >  > > _______________________________________________ > Matplotlibusers mailing list > Matplotlibusers@... > https://lists.sourceforge.net/lists/listinfo/matplotlibusers 
From: CohenTanugi Johann <cohen@lp...>  20090401 21:06:04

I tried to look at the code (axes.py I presume) in order to attempt a patch, but it defeated me, I do not have the instructions to navigate through this code :) Where is the actual transform of the error bars occurring? thanks, Johann Michael Droettboom wrote: > I have to say I don't really have a lot of experience with error bars > on log plots  but the root cause here is that the lower bound of the > error bar goes negative, and as we all know, the log of a negative > number is undefined. If you can suggest where the lower bound should > be drawn or provide thirdparty examples, I'm happy to look into this > further and resolve this "surprise". > > Mike > > CohenTanugi Johann wrote: >> yes exactly.... >> I should have provided a test case, thanks for following up! >> Johann >> >> Matthias Michler wrote: >> >>> Hello Johann, >>> >>> is the problem you are reporting the one I observe in the attached >>> picture? Namely some vertical and horizontal lines are missing when >>> using yscale="log". More precisely everything below y=1 seems to be >>> missing. >>> >>> The picture was generated with the code below and >>> matplotlib.__version__ = '0.98.6svn' >>> matplotlib.__revision__ = '$Revision: 6887 $' >>> >>> best regards Matthias >>> >>> ############################### >>> import numpy as np >>> import matplotlib.pyplot as plt >>> >>> plt.subplot(111, xscale="log", yscale="log") >>> x = 10.0**np.linspace(0.0, 2.0, 20) >>> y = x**2.0 >>> plt.errorbar(x, y, xerr=0.1*x, yerr=5.0+0.75*y) >>> plt.show() >>> ################################ >>> On Friday 27 March 2009 16:12:12 CohenTanugi Johann wrote: >>> >>>> Hello, what is the best way to get log log plots with error bars? I >>>> tried putting log10() everywhere but as I was afraid results look >>>> ugly.... >>>> thanks, >>>> johann >>>> >>>>  >>>> >>>> >>>>  >>>> >>>> >>>>  >>>> >>>> >>>>  >>>> >>>> >>>> _______________________________________________ >>>> Matplotlibusers mailing list >>>> Matplotlibusers@... >>>> https://lists.sourceforge.net/lists/listinfo/matplotlibusers >>>> >> >>  >> >> _______________________________________________ >> Matplotlibusers mailing list >> Matplotlibusers@... >> https://lists.sourceforge.net/lists/listinfo/matplotlibusers >> > 
From: CohenTanugi Johann <cohen@lp...>  20090403 06:03:32

hello..... Anyone? I would very much love to see this fixed, and I am ready to help out, but I do not know how to browse through the code. Despite the fact that log(errors) should of course not be used, but rathter errors/values/log(10), Michael's point still remains : values errors in log scale can be negative, so that the artist should just draw a bar until the lower limit of the vertical bar. I would say that this is the standard practice. Sorry for my previous email beside the point. Johann CohenTanugi Johann wrote: > I tried to look at the code (axes.py I presume) in order to attempt a > patch, but it defeated me, I do not have the instructions to navigate > through this code :) > Where is the actual transform of the error bars occurring? > thanks, > Johann > > Michael Droettboom wrote: > >> I have to say I don't really have a lot of experience with error bars >> on log plots  but the root cause here is that the lower bound of the >> error bar goes negative, and as we all know, the log of a negative >> number is undefined. If you can suggest where the lower bound should >> be drawn or provide thirdparty examples, I'm happy to look into this >> further and resolve this "surprise". >> >> Mike >> >> CohenTanugi Johann wrote: >> >>> yes exactly.... >>> I should have provided a test case, thanks for following up! >>> Johann >>> >>> Matthias Michler wrote: >>> >>> >>>> Hello Johann, >>>> >>>> is the problem you are reporting the one I observe in the attached >>>> picture? Namely some vertical and horizontal lines are missing when >>>> using yscale="log". More precisely everything below y=1 seems to be >>>> missing. >>>> >>>> The picture was generated with the code below and >>>> matplotlib.__version__ = '0.98.6svn' >>>> matplotlib.__revision__ = '$Revision: 6887 $' >>>> >>>> best regards Matthias >>>> >>>> ############################### >>>> import numpy as np >>>> import matplotlib.pyplot as plt >>>> >>>> plt.subplot(111, xscale="log", yscale="log") >>>> x = 10.0**np.linspace(0.0, 2.0, 20) >>>> y = x**2.0 >>>> plt.errorbar(x, y, xerr=0.1*x, yerr=5.0+0.75*y) >>>> plt.show() >>>> ################################ >>>> On Friday 27 March 2009 16:12:12 CohenTanugi Johann wrote: >>>> >>>> >>>>> Hello, what is the best way to get log log plots with error bars? I >>>>> tried putting log10() everywhere but as I was afraid results look >>>>> ugly.... >>>>> thanks, >>>>> johann >>>>> >>>>>  >>>>> >>>>> >>>>>  >>>>> >>>>> >>>>>  >>>>> >>>>> >>>>>  >>>>> >>>>> >>>>> _______________________________________________ >>>>> Matplotlibusers mailing list >>>>> Matplotlibusers@... >>>>> https://lists.sourceforge.net/lists/listinfo/matplotlibusers >>>>> >>>>> >>>  >>> >>> _______________________________________________ >>> Matplotlibusers mailing list >>> Matplotlibusers@... >>> https://lists.sourceforge.net/lists/listinfo/matplotlibusers >>> >>> > >  > _______________________________________________ > Matplotlibusers mailing list > Matplotlibusers@... > https://lists.sourceforge.net/lists/listinfo/matplotlibusers > 
From: Eric Firing <efiring@ha...>  20090403 07:32:00

CohenTanugi Johann wrote: > I tried to look at the code (axes.py I presume) in order to attempt a > patch, but it defeated me, I do not have the instructions to navigate > through this code :) > Where is the actual transform of the error bars occurring? I think it is in the draw (or recache) method of the artists. The right way to handle this problem is not obvious to me. Maybe with a variant of the log scale that clips instead of masking invalid points. And maybe instead of making a whole set of such variants, the behaviormasking versus clipping, and the clip level if the lattershould be handled by an rcParam. Eric > thanks, > Johann > > Michael Droettboom wrote: >> I have to say I don't really have a lot of experience with error bars >> on log plots  but the root cause here is that the lower bound of the >> error bar goes negative, and as we all know, the log of a negative >> number is undefined. If you can suggest where the lower bound should >> be drawn or provide thirdparty examples, I'm happy to look into this >> further and resolve this "surprise". >> >> Mike >> >> CohenTanugi Johann wrote: >>> yes exactly.... >>> I should have provided a test case, thanks for following up! >>> Johann >>> >>> Matthias Michler wrote: >>> >>>> Hello Johann, >>>> >>>> is the problem you are reporting the one I observe in the attached >>>> picture? Namely some vertical and horizontal lines are missing when >>>> using yscale="log". More precisely everything below y=1 seems to be >>>> missing. >>>> >>>> The picture was generated with the code below and >>>> matplotlib.__version__ = '0.98.6svn' >>>> matplotlib.__revision__ = '$Revision: 6887 $' >>>> >>>> best regards Matthias >>>> >>>> ############################### >>>> import numpy as np >>>> import matplotlib.pyplot as plt >>>> >>>> plt.subplot(111, xscale="log", yscale="log") >>>> x = 10.0**np.linspace(0.0, 2.0, 20) >>>> y = x**2.0 >>>> plt.errorbar(x, y, xerr=0.1*x, yerr=5.0+0.75*y) >>>> plt.show() >>>> ################################ >>>> On Friday 27 March 2009 16:12:12 CohenTanugi Johann wrote: >>>> >>>>> Hello, what is the best way to get log log plots with error bars? I >>>>> tried putting log10() everywhere but as I was afraid results look >>>>> ugly.... >>>>> thanks, >>>>> johann 
From: Michael Droettboom <mdroe@st...>  20090403 20:37:30

It looks like you're all heading down the right path. I'm happy to help (as the original author of the transforms code), but I'm going to be generally unavailable until Thursday or Friday of next week. Cheers, Mike Eric Firing wrote: > CohenTanugi Johann wrote: >> I tried to look at the code (axes.py I presume) in order to attempt a >> patch, but it defeated me, I do not have the instructions to >> navigate through this code :) >> Where is the actual transform of the error bars occurring? > > I think it is in the draw (or recache) method of the artists. > > The right way to handle this problem is not obvious to me. Maybe with > a variant of the log scale that clips instead of masking invalid > points. And maybe instead of making a whole set of such variants, the > behaviormasking versus clipping, and the clip level if the > lattershould be handled by an rcParam. > > Eric > >> thanks, >> Johann >> >> Michael Droettboom wrote: >>> I have to say I don't really have a lot of experience with error >>> bars on log plots  but the root cause here is that the lower bound >>> of the error bar goes negative, and as we all know, the log of a >>> negative number is undefined. If you can suggest where the lower >>> bound should be drawn or provide thirdparty examples, I'm happy to >>> look into this further and resolve this "surprise". >>> >>> Mike >>> >>> CohenTanugi Johann wrote: >>>> yes exactly.... >>>> I should have provided a test case, thanks for following up! >>>> Johann >>>> >>>> Matthias Michler wrote: >>>> >>>>> Hello Johann, >>>>> >>>>> is the problem you are reporting the one I observe in the attached >>>>> picture? Namely some vertical and horizontal lines are missing >>>>> when using yscale="log". More precisely everything below y=1 seems >>>>> to be missing. >>>>> >>>>> The picture was generated with the code below and >>>>> matplotlib.__version__ = '0.98.6svn' >>>>> matplotlib.__revision__ = '$Revision: 6887 $' >>>>> >>>>> best regards Matthias >>>>> >>>>> ############################### >>>>> import numpy as np >>>>> import matplotlib.pyplot as plt >>>>> >>>>> plt.subplot(111, xscale="log", yscale="log") >>>>> x = 10.0**np.linspace(0.0, 2.0, 20) >>>>> y = x**2.0 >>>>> plt.errorbar(x, y, xerr=0.1*x, yerr=5.0+0.75*y) >>>>> plt.show() >>>>> ################################ >>>>> On Friday 27 March 2009 16:12:12 CohenTanugi Johann wrote: >>>>> >>>>>> Hello, what is the best way to get log log plots with error bars? I >>>>>> tried putting log10() everywhere but as I was afraid results look >>>>>> ugly.... >>>>>> thanks, >>>>>> johann  Michael Droettboom Science Software Branch Operations and Engineering Division Space Telescope Science Institute Operated by AURA for NASA 
From: Eric Firing <efiring@ha...>  20090404 23:11:49

CohenTanugi Johann wrote: > ok, maybe it is in scale.py :) > And what I see there confirms my initial fears : the log scale transform > applies a log to the argument, which is incorrect for an error..... So > first of all, another transform needs to be created so that erry is > transformed into erry/y/log(base) where base was 10 in my example. Johann, I don't understand your objection here. It seems to me that an errorbar should always be in the same units, and on the same scale, as the point to which it applies. Therefore when switching from linear to log scales, one simply plots the same data and error ranges on a log scale instead of a linear scale. This is what mpl does. If what you want is for the error to be proportional to the value of the point, then you need to specify the error bounds so that they have that property. For estimation of a power spectrum, for example, this is often the case; the error bars are some fraction (depending on the equivalent number of degrees of freedom) of the spectral level at each frequency, so on a log plot they will have equal length. It is not the job of the errorbar function to figure that out, however. If I am misunderstanding, then please provide a very simple concrete example that will make your point clear. > > past midnight here.... I will see tomorrow if I find time to try out a > patch (not the easiest entry point for starting developer's activities > in MPL I am afraid....) I have just committed a change (trunk r7023) that allows nonpositive numbers to be clipped to a small positive value. To illustrate its use with an errorbar, I added the example provided by Matthias to examples/pylab_examples/log_demo.py, as a 4th subplot. Eric > > Johann 
From: CohenTanugi Johann <cohen@lp...>  20090404 23:31:08

hi Eric, then I misunderstood what the code does.... I thought it was transforming the data. In any case, my second figure in my previous post is wrong because the code should read: plt.errorbar(cE,corrE*fluxes, yerr=corrE*unc_fluxes) instead of plt.errorbar(cE,corrE*fluxes, yerr=unc_fluxes) and indeed this seems to behave correctly, so I guess I got completely confused while trying to understand what was happening. I will check out your patch and start from the beginning. thanks a lot and sorry, Johann Eric Firing wrote: > CohenTanugi Johann wrote: >> ok, maybe it is in scale.py :) >> And what I see there confirms my initial fears : the log scale >> transform applies a log to the argument, which is incorrect for an >> error..... So first of all, another transform needs to be created so >> that erry is transformed into erry/y/log(base) where base was 10 in >> my example. > > Johann, > > I don't understand your objection here. It seems to me that an > errorbar should always be in the same units, and on the same scale, > as the point to which it applies. Therefore when switching from > linear to log scales, one simply plots the same data and error ranges > on a log scale instead of a linear scale. This is what mpl does. If > what you want is for the error to be proportional to the value of the > point, then you need to specify the error bounds so that they have > that property. For estimation of a power spectrum, for example, this > is often the case; the error bars are some fraction (depending on the > equivalent number of degrees of freedom) of the spectral level at each > frequency, so on a log plot they will have equal length. It is not > the job of the errorbar function to figure that out, however. > > If I am misunderstanding, then please provide a very simple concrete > example that will make your point clear. > >> >> past midnight here.... I will see tomorrow if I find time to try out >> a patch (not the easiest entry point for starting developer's >> activities in MPL I am afraid....) > > I have just committed a change (trunk r7023) that allows nonpositive > numbers to be clipped to a small positive value. To illustrate its > use with an errorbar, I added the example provided by Matthias to > examples/pylab_examples/log_demo.py, as a 4th subplot. > > Eric >> >> Johann 
From: CohenTanugi Johann <cohen@lp...>  20090405 00:19:11

indeed, I obviously just got entangled in my own debugging. I do manage to get it to do what I want now. sorry for the fuss, Johann Eric Firing wrote: > CohenTanugi Johann wrote: >> ok, maybe it is in scale.py :) >> And what I see there confirms my initial fears : the log scale >> transform applies a log to the argument, which is incorrect for an >> error..... So first of all, another transform needs to be created so >> that erry is transformed into erry/y/log(base) where base was 10 in >> my example. > > Johann, > > I don't understand your objection here. It seems to me that an > errorbar should always be in the same units, and on the same scale, > as the point to which it applies. Therefore when switching from > linear to log scales, one simply plots the same data and error ranges > on a log scale instead of a linear scale. This is what mpl does. If > what you want is for the error to be proportional to the value of the > point, then you need to specify the error bounds so that they have > that property. For estimation of a power spectrum, for example, this > is often the case; the error bars are some fraction (depending on the > equivalent number of degrees of freedom) of the spectral level at each > frequency, so on a log plot they will have equal length. It is not > the job of the errorbar function to figure that out, however. > > If I am misunderstanding, then please provide a very simple concrete > example that will make your point clear. > >> >> past midnight here.... I will see tomorrow if I find time to try out >> a patch (not the easiest entry point for starting developer's >> activities in MPL I am afraid....) > > I have just committed a change (trunk r7023) that allows nonpositive > numbers to be clipped to a small positive value. To illustrate its > use with an errorbar, I added the example provided by Matthias to > examples/pylab_examples/log_demo.py, as a 4th subplot. > > Eric >> >> Johann 
From: Eric Firing <efiring@ha...>  20090405 01:08:19

CohenTanugi Johann wrote: > indeed, I obviously just got entangled in my own debugging. I do manage > to get it to do what I want now. > > sorry for the fuss, > Johann No problem at all. I'm glad things are working for you. Eric 