-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Errorbar: do not ignore inf but plot errorbar bigger than current frame size #7876
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
http://matplotlib.org/examples/statistics/errorbar_limits.html is another way this can be dealt with which requires a bit more user input to interpret what and 'infinite' errorbar means. It might be possible to automatically do something like that in the case of inf. I think another reasonable approach to the error being inf is to drop the point altogether (likely making too many assumptions to be in mpl) as if the error is infinite, then the number is effectively meaningless. |
Thanks for the link but it does not really help in my situation. If instead inf errors would fill the complete direction (but not count towards the limits), I would show this difference. Also, if I prefer to not have this range filling error bar, I can just replace infs with nans and have the old back. |
On 2017/01/19 9:02 AM, FrederikLauber wrote:
The problem arises if you have a bin with a single entry.
With that, the std becomes infinite.
I disagree. I think it should be viewed as undefined--utterly
meaningless. It does not make sense to have an errorbar at all in such
a case. Maybe what you need to do is use a different symbol or color
for such points with no valid errorbar.
|
Hi, well, its math, if you have a Bessel correction in your error formular( i.e. 1/(N-1)) the error will always become infinite for singular events which makes total sense. A singular measurement does usually tell you nothing which is indicated by a infinite error on the value (you get the same for a fit through a singular data point, the parameters will be random with an infinite error). If you pick a different error formular, you might not get to inf but most error formuars I know contain a Bessel correction due to being an estimator to the actual error because the actual error is normally not known. Either way, its not matplotlib which should decide to drop this from my plotting but me. And displaying an error bigger then the frame will 1. indicate to the user what is going on at the data point, if he does not like it, he can either revert to the nan behaviour very easily or choose some other way to reflect this) 2. does not get confused with an nonexistent or close to 0 error bar. |
While I agree with @efiring that infinite error doesn't make sense, I agree with @FrederikLauber on deferring to the user. I support the idea of just extending a line to the axis extent as that technically won't change the API. Maybe matplotlib should raise a warning as to that being what it's doing, but that might be clutter... |
On 2017/01/23 11:30 AM, FrederikLauber wrote:
well, its math, if you have a Bessel correction in your error formular(
i.e. 1/(N-1)) the error will always become infinite
No, it's not math, it's the choice that was made by IEEE. In math,
division by zero is undefined. I think Wikipedia has it right:
https://en.wikipedia.org/wiki/Division_by_zero.
Similarly, standard deviation or SEM cannot be estimated from a single
sample; it is not infinite, it is undefined.
|
I am running into this issue in the context of a forest-plot-style comparison of median estimates from survival regressions. I am using the (2,N) shaped form of |
@zmbc You should look at the |
Yes, I vote that this be closed... |
@tacaswell I did, and unless I'm missing something |
Can you get the desired effect by substituting a very large number for the |
@zmbc 🐑 Sorry, I answered too quickly and was mistaken about exactly what that API did (I remembered the arrow up/down, but not that it dropped the other side). I am inclined to re-open this (or open a new issue) to track the request from "real error in one direction, line with arrow in the other". I am not sure that "off the screen" is the right thing for us to ever do by default because that suggest that there might be a real value out there if you changed the limits right (and I do not recall off the top of my head if auto-limits take in to account error bars...I hope they do). I think the right thing is something like |
Good idea @efiring, I will do that for now. I agree that the arrow would be preferable to an infinitely-extending line. |
I opened #22980 to track the idea of using an arrow... |
Uh oh!
There was an error while loading. Please reload this page.
Hi,
if you run this code:
you will get this figure:
As you can see, both the error bar at 3 and 9 are missing. 3 has an error of "nan", so leaving out the error bar to indicate this is fine in my eyes. 9 has "inf" and also has no error bar. I think it would be better, if this error bar would be bigger then the frame of the figure.
Hence you would see that the error is at this point is bigger then the current y limits and not confuse this with a non existent error. Also in plots with vastly different error bars, an infinite error can no longer be confused with an error of size 0.
Thanks in advance,
The text was updated successfully, but these errors were encountered: