Skip to content

Commit

Permalink
add check for negative errors, convert to positive
Browse files Browse the repository at this point in the history
  • Loading branch information
jhaigh0 committed Sep 16, 2024
1 parent 1a4dba4 commit 9af6452
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Framework/PythonInterface/mantid/plots/axesfunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
)
from mantid.plots.utility import MantidAxType
from mantid.plots.quad_mesh_wrapper import QuadMeshWrapper
from mantid import logger

# Used for initializing searches of max, min values
_LARGEST, _SMALLEST = float(sys.maxsize), -sys.maxsize
Expand Down Expand Up @@ -286,6 +287,14 @@ def errorbar(axes, workspace, *args, **kwargs):
_setLabels1D(axes, workspace, indices, normalize_by_bin_width=normalize_by_bin_width, axis=axis)
kwargs.pop("normalize_by_bin_width", None)

if dy is not None and min(dy) < 0:
dy = abs(dy)
logger.warning("Negative values found in y error when plotting error bars. Converting to positive and continuing.")

if dx is not None and min(dx) < 0:
dx = abs(dx)
logger.warning("Negative values found in x error when plotting error bars. Converting to positive and continuing.")

return axes.errorbar(x, y, dy, dx, *args, **kwargs)


Expand Down

0 comments on commit 9af6452

Please sign in to comment.