Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreRaybaut committed Jan 13, 2025
2 parents d0b5e26 + fbae8a2 commit 1c1d609
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions qwt/scale_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,15 +198,15 @@ def __init__(self, base=10):
self.__data = QwtScaleEngine_PrivateData()
self.setBase(base)

def autoScale(self, maxNumSteps, x1, x2, stepSize, relative_margin=0.0):
def autoScale(self, maxNumSteps, x1, x2, stepSize, relativeMargin=0.0):
"""
Align and divide an interval
:param int maxNumSteps: Max. number of steps
:param float x1: First limit of the interval (In/Out)
:param float x2: Second limit of the interval (In/Out)
:param float stepSize: Step size
:param float relative_margin: Margin as a fraction of the interval width
:param float relativeMargin: Margin as a fraction of the interval width
:return: tuple (x1, x2, stepSize)
"""
pass
Expand Down Expand Up @@ -474,24 +474,24 @@ class QwtLinearScaleEngine(QwtScaleEngine):
def __init__(self, base=10):
super(QwtLinearScaleEngine, self).__init__(base)

def autoScale(self, maxNumSteps, x1, x2, stepSize, relative_margin=0.0):
def autoScale(self, maxNumSteps, x1, x2, stepSize, relativeMargin=0.0):
"""
Align and divide an interval
:param int maxNumSteps: Max. number of steps
:param float x1: First limit of the interval (In/Out)
:param float x2: Second limit of the interval (In/Out)
:param float stepSize: Step size
:param float relative_margin: Margin as a fraction of the interval width
:param float relativeMargin: Margin as a fraction of the interval width
:return: tuple (x1, x2, stepSize)
.. seealso::
:py:meth:`setAttribute()`
"""
# Apply the relative margin (fraction of the interval width) in linear space:
if relative_margin > 0.0:
margin = (x2 - x1) * relative_margin
if relativeMargin > 0.0:
margin = (x2 - x1) * relativeMargin
x1 -= margin
x2 += margin

Expand Down Expand Up @@ -648,15 +648,15 @@ def __init__(self, base=10):
super(QwtLogScaleEngine, self).__init__(base)
self.setTransformation(QwtLogTransform())

def autoScale(self, maxNumSteps, x1, x2, stepSize, relative_margin=0.0):
def autoScale(self, maxNumSteps, x1, x2, stepSize, relativeMargin=0.0):
"""
Align and divide an interval
:param int maxNumSteps: Max. number of steps
:param float x1: First limit of the interval (In/Out)
:param float x2: Second limit of the interval (In/Out)
:param float stepSize: Step size
:param float relative_margin: Margin as a fraction of the interval width
:param float relativeMargin: Margin as a fraction of the interval width
:return: tuple (x1, x2, stepSize)
.. seealso::
Expand All @@ -669,10 +669,10 @@ 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:
if relativeMargin 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
log_margin = math.log(x2 / x1, logBase) * relativeMargin
x1 /= math.pow(logBase, log_margin)
x2 *= math.pow(logBase, log_margin)

Expand Down

0 comments on commit 1c1d609

Please sign in to comment.