Skip to content

Commit

Permalink
Fix logarithmic scale bounds to ensure values stay within defined limits
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreRaybaut committed Dec 31, 2024
1 parent 0e44c89 commit c652e81
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions qwt/scale_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,8 @@ def autoScale(self, maxNumSteps, x1, x2, stepSize, relative_margin=0.0):
# Apply the relative margin (fraction of the interval width) in logarithmic
# space, and convert back to linear space.
if relative_margin is not None:
x1 = min(max([x1, LOG_MIN]), LOG_MAX)
x2 = min(max([x2, LOG_MIN]), LOG_MAX)
log_margin = math.log(x2 / x1, logBase) * relative_margin
x1 /= math.pow(logBase, log_margin)
x2 *= math.pow(logBase, log_margin)
Expand Down

0 comments on commit c652e81

Please sign in to comment.