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 y-errors into y-errors/y-values/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 y-scale 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


Cohen-Tanugi 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

Cohen-Tanugi 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 third-party examples, I'm happy to look into this further and resolve this "surprise".

Mike

Cohen-Tanugi 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 Cohen-Tanugi 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
------------------------------------------------------------------------

------------------------------------------------------------------------

------------------------------------------------------------------------------ ------------------------------------------------------------------------

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
------------------------------------------------------------------------------
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

------------------------------------------------------------------------------
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

<<inline: image2.png>>

<<inline: image1.png>>

import pyfits
import numpy as np
import matplotlib.pylab as plt

pwl_gamma=2.2482419

lowE=np.array([   100.,    300.,   1000.,   3000.,  10000.], dtype=np.float32)
hiE= np.array([    300.,    1000.,    3000.,   10000.,  100000.], dtype=np.float32)
cE=np.sqrt(lowE*hiE)
#see https://confluence.slac.stanford.edu/display/SCIGRPS/Source+catalog+format
corrE= cE**(2-pwl_gamma) * (pwl_gamma-1.) / (lowE**(1.-pwl_gamma) - hiE**(1.-pwl_gamma))

fluxes=np.array([  8.12756468e-07,   3.01217426e-07,   7.27334069e-08,
         1.19868124e-08,   2.56514854e-09], dtype=np.float32)
unc_fluxes=np.array([  1.15193671e-07,   1.32578517e-08,   3.46157170e-09,
         1.13887966e-09,   4.41060244e-10], dtype=np.float32)

plt.errorbar(np.log10(cE),np.log10(corrE*fluxes),  yerr=unc_fluxes/fluxes/np.log(10))

plt.figure()
plt.errorbar(cE,corrE*fluxes, yerr=unc_fluxes)
a=plt.gca()
a.set_xscale('log')
a.set_yscale('log')
------------------------------------------------------------------------------
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to