FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Errorbar semilogy switch to log y removed error bars when crosses into negative · Issue #9149 · matplotlib/matplotlib · GitHub

Repository navigation

Errorbar semilogy switch to log y removed error bars when crosses into negative #9149

Closed as not planned

Description

Bug report

Bug summary

When plotting error bars on data points, where the data is positive but the bar with the data-error is entering negative values, switching to log Y axes using semilogy() means that some data points are plotted without error bars at all (both y-err bars disappear).

Code for reproduction

create a file example.dat:
x dx y dy
1.046850 0.0029168 0.042551 0.02420
1.506679 0.0030152 0.027573 0.02252
3.028597 0.1959554 0.021218 0.00974
3.656348 0.1034119 0.002788 0.01059
4.949535 0.4693247 0.006276 0.00969

from astropy.io import ascii
from pylab import figure, errorbar,semilogy
t = ascii.read('example.dat')
figure()
errorbar(t['x'],t['y'],xerr=t['dx'],yerr=t['dy'],fmt='s')

This shows a linear plot with errorbars fine. The third data point error bar extends into negative territory.

semilogy()

Now the plot has a log y axis, but the error bar of the third point is gone.

# Paste your code here
#
#

from astropy.io import ascii
from pylab import figure, errorbar,semilogy
t = ascii.read('example.dat')
figure()
errorbar(t['x'],t['y'],xerr=t['dx'],yerr=t['dy'],fmt='s')

#This shows a linear plot with errorbars fine. The third data point error bar extends into negative territory.

semilogy()

#Now the plot has a log y axis, but the error bar of the third point is gone.
Actual outcome

# If applicable, paste the console output here
#
#

Expected outcome

An errorbar in the log plot, surely the positive bar, and the negative going a few (3 or 5) decades down (perhaps with an arrow ending).

Matplotlib version

  • Operating System: OSX
  • Matplotlib Version: 2.0.2
  • Python Version:2.7
  • Jupyter Version (if applicable):
  • Other Libraries: astropy

anaconda astroconda

Activity

  1. dstansby commented on Sep 1, 2017

    Member

    Yeah, we change the behaviour of this recently to fix some other issues (#8836). There is a note in the docstring of errorbar that what you're describing is expected behaviour, but I do agree that we should find some way to put the errorbars back in and have them go right down.

  2. added this to the milestone on Sep 1, 2017
  3. tacaswell commented on Sep 1, 2017

    Member

    I think the issue here is that exactly what should be done with the negative is not clear, I think there are at least 4 options:

    • mask the bottom point and drop the whole errorbar (it is implemented as a single line)
    • mask the bottom point, but still draw the top half (not done, but would be possible without too much trouble)
    • clip to some 'small' number (now picking that small number is it's own issue and now we have to be careful on auto-scaling to not include that in the limits) (and this is implemented via a kwarg flag)
      • should we clip to 0+epsilon or val * epsilon? (I think we go with the first option now, but would have to check the code)
    • replace the bottom one with an arrow, but this also has to be clipped so the difference is still positive so we have to pick that number

    See https://matplotlib.org/examples/statistics/errorbar_limits.html for all the ways to have finer grain control over how limits are drawn (if you want to use log then negative values are probably non-physical and you really just have no lower bound for the value (ex neutrino mass)) so it might be worth doing the extra work to identify that.

    Also see https://matplotlib.org/api/_as_gen/matplotlib.axes.Axes.set_yscale.html , if you use ax.set_yscale('log', nonposy='clip') it should clip the error bars to some very small number.

  4. github-actions commented on Apr 17, 2023

    This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!

  5. added
    status: closed as inactiveIssues closed by the "Stale" Github Action. Please comment on any you think should still be open.
    on May 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: closed as inactiveIssues closed by the "Stale" Github Action. Please comment on any you think should still be open.status: inactiveMarked by the “Stale” Github Action

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL