Scales

QwtScaleWidget

class qwt.scale_widget.QwtScaleWidget(*args)[source]

A Widget which contains a scale

This Widget can be used to decorate composite widgets with a scale.

Layout flags:

  • QwtScaleWidget.TitleInverted: The title of vertical scales is painted from top to bottom. Otherwise it is painted from bottom to top.
class QwtScaleWidget([parent=None])

Alignment default is QwtScaleDraw.LeftScale.

Parameters:parent (QWidget or None) – Parent widget
class qwt.scale_widget.QwtScaleWidget(align, parent)[source]
Parameters:
  • align (int) – Alignment
  • parent (QWidget) – Parent widget
QwtScaleWidget.initScale(align)[source]

Initialize the scale

Parameters:align (int) – Alignment
QwtScaleWidget.setLayoutFlag(flag, on=True)[source]

Toggle an layout flag

Parameters:
  • flag (int) – Layout flag
  • on (bool) – True/False

See also

testLayoutFlag()

QwtScaleWidget.testLayoutFlag(flag)[source]

Test a layout flag

Parameters:flag (int) – Layout flag
Returns:True/False

See also

setLayoutFlag()

QwtScaleWidget.setTitle(title)[source]

Give title new text contents

Parameters:title (qwt.text.QwtText or str) – New title

See also

title()

QwtScaleWidget.setAlignment(alignment)[source]

Change the alignment

Parameters:alignment (int) – New alignment

Valid alignment values: see qwt.scale_draw.QwtScaleDraw

See also

alignment()

QwtScaleWidget.alignment()[source]
Returns:position

See also

setAlignment()

QwtScaleWidget.setBorderDist(dist1, dist2)[source]

Specify distances of the scale’s endpoints from the widget’s borders. The actual borders will never be less than minimum border distance.

Parameters:
  • dist1 (int) – Left or top Distance
  • dist2 (int) – Right or bottom distance

See also

borderDist()

QwtScaleWidget.setMargin(margin)[source]

Specify the margin to the colorBar/base line.

Parameters:margin (int) – Margin

See also

margin()

QwtScaleWidget.setSpacing(spacing)[source]

Specify the distance between color bar, scale and title

Parameters:spacing (int) – Spacing

See also

spacing()

QwtScaleWidget.setLabelAlignment(alignment)[source]

Change the alignment for the labels.

Parameters:spacing (int) – Spacing

See also

QwtScaleDraw.setLabelAlignment(), setLabelRotation()

QwtScaleWidget.setLabelRotation(rotation)[source]

Change the rotation for the labels.

Parameters:rotation (float) – Rotation

See also

QwtScaleDraw.setLabelRotation(), setLabelFlags()

QwtScaleWidget.setScaleDraw(scaleDraw)[source]

Set a scale draw

scaleDraw has to be created with new and will be deleted in class destructor or the next call of setScaleDraw(). scaleDraw will be initialized with the attributes of the previous scaleDraw object.

Parameters:scaleDraw (qwt.scale_draw.QwtScaleDraw) – ScaleDraw object

See also

scaleDraw()

QwtScaleWidget.scaleDraw()[source]
Returns:scaleDraw of this scale

See also

QwtScaleDraw.setScaleDraw()

QwtScaleWidget.title()[source]
Returns:title

See also

setTitle()

QwtScaleWidget.startBorderDist()[source]
Returns:start border distance

See also

setBorderDist()

QwtScaleWidget.endBorderDist()[source]
Returns:end border distance

See also

setBorderDist()

QwtScaleWidget.margin()[source]
Returns:margin

See also

setMargin()

QwtScaleWidget.spacing()[source]
Returns:distance between scale and title

See also

setSpacing()

QwtScaleWidget.draw(painter)[source]

Draw the scale

Parameters:painter (QPainter) – Painter
QwtScaleWidget.colorBarRect(rect)[source]

Calculate the the rectangle for the color bar

Parameters:rect (QRectF) – Bounding rectangle for all components of the scale
Returns:Rectangle for the color bar
QwtScaleWidget.layoutScale(update_geometry=True)[source]

Recalculate the scale’s geometry and layout based on the current geometry and fonts.

Parameters:update_geometry (bool) – Notify the layout system and call update to redraw the scale
QwtScaleWidget.drawColorBar(painter, rect)[source]

Draw the color bar of the scale widget

Parameters:
  • painter (QPainter) – Painter
  • rect (QRectF) – Bounding rectangle for the color bar
QwtScaleWidget.drawTitle(painter, align, rect)[source]

Rotate and paint a title according to its position into a given rectangle.

Parameters:
  • painter (QPainter) – Painter
  • align (int) – Alignment
  • rect (QRectF) – Bounding rectangle
QwtScaleWidget.scaleChange()[source]

Notify a change of the scale

This method can be overloaded by derived classes. The default implementation updates the geometry and repaints the widget.

QwtScaleWidget.titleHeightForWidth(width)[source]

Find the height of the title for a given width.

Parameters:width (int) – Width
Returns:Height
QwtScaleWidget.dimForLength(length, scaleFont)[source]

Find the minimum dimension for a given length. dim is the height, length the width seen in direction of the title.

Parameters:
  • length (int) – width for horizontal, height for vertical scales
  • scaleFont (QFont) – Font of the scale
Returns:

height for horizontal, width for vertical scales

QwtScaleWidget.getBorderDistHint()[source]

Calculate a hint for the border distances.

This member function calculates the distance of the scale’s endpoints from the widget borders which is required for the mark labels to fit into the widget. The maximum of this distance an the minimum border distance is returned.

Parameters:
  • start (int) – Return parameter for the border width at the beginning of the scale
  • end (int) – Return parameter for the border width at the end of the scale

Warning

The minimum border distance depends on the font.

QwtScaleWidget.setMinBorderDist(start, end)[source]

Set a minimum value for the distances of the scale’s endpoints from the widget borders. This is useful to avoid that the scales are “jumping”, when the tick labels or their positions change often.

Parameters:
  • start (int) – Minimum for the start border
  • end (int) – Minimum for the end border
QwtScaleWidget.getMinBorderDist()[source]

Get the minimum value for the distances of the scale’s endpoints from the widget borders.

Parameters:
  • start (int) – Return parameter for the border width at the beginning of the scale
  • end (int) – Return parameter for the border width at the end of the scale
QwtScaleWidget.setScaleDiv(scaleDiv)[source]

Assign a scale division

The scale division determines where to set the tick marks.

Parameters:scaleDiv (qwt.scale_div.QwtScaleDiv) – Scale Division

See also

For more information about scale divisions, see qwt.scale_div.QwtScaleDiv.

QwtScaleWidget.setTransformation(transformation)[source]

Set the transformation

Parameters:transformation (qwt.transform.Transform) – Transformation

See also

qwt.scale_draw.QwtAbstractScaleDraw.scaleDraw(), qwt.scale_map.QwtScaleMap

QwtScaleWidget.setColorBarEnabled(on)[source]

En/disable a color bar associated to the scale

Parameters:on (bool) – On/Off
QwtScaleWidget.isColorBarEnabled()[source]
Returns:True, when the color bar is enabled
QwtScaleWidget.setColorBarWidth(width)[source]

Set the width of the color bar

Parameters:width (int) – Width
QwtScaleWidget.colorBarWidth()[source]
Returns:Width of the color bar
QwtScaleWidget.colorBarInterval()[source]
Returns:Value interval for the color bar
QwtScaleWidget.setColorMap(interval, colorMap)[source]

Set the color map and value interval, that are used for displaying the color bar.

Parameters:
QwtScaleWidget.colorMap()[source]
Returns:Color map
class qwt.scale_widget.QwtScaleWidget(*args)[source]

A Widget which contains a scale

This Widget can be used to decorate composite widgets with a scale.

Layout flags:

  • QwtScaleWidget.TitleInverted: The title of vertical scales is painted from top to bottom. Otherwise it is painted from bottom to top.
class QwtScaleWidget([parent=None])

Alignment default is QwtScaleDraw.LeftScale.

Parameters:parent (QWidget or None) – Parent widget
class qwt.scale_widget.QwtScaleWidget(align, parent)[source]
Parameters:
  • align (int) – Alignment
  • parent (QWidget) – Parent widget
QwtScaleWidget.initScale(align)[source]

Initialize the scale

Parameters:align (int) – Alignment
QwtScaleWidget.setLayoutFlag(flag, on=True)[source]

Toggle an layout flag

Parameters:
  • flag (int) – Layout flag
  • on (bool) – True/False

See also

testLayoutFlag()

QwtScaleWidget.testLayoutFlag(flag)[source]

Test a layout flag

Parameters:flag (int) – Layout flag
Returns:True/False

See also

setLayoutFlag()

QwtScaleWidget.setTitle(title)[source]

Give title new text contents

Parameters:title (qwt.text.QwtText or str) – New title

See also

title()

QwtScaleWidget.setAlignment(alignment)[source]

Change the alignment

Parameters:alignment (int) – New alignment

Valid alignment values: see qwt.scale_draw.QwtScaleDraw

See also

alignment()

QwtScaleWidget.alignment()[source]
Returns:position

See also

setAlignment()

QwtScaleWidget.setBorderDist(dist1, dist2)[source]

Specify distances of the scale’s endpoints from the widget’s borders. The actual borders will never be less than minimum border distance.

Parameters:
  • dist1 (int) – Left or top Distance
  • dist2 (int) – Right or bottom distance

See also

borderDist()

QwtScaleWidget.setMargin(margin)[source]

Specify the margin to the colorBar/base line.

Parameters:margin (int) – Margin

See also

margin()

QwtScaleWidget.setSpacing(spacing)[source]

Specify the distance between color bar, scale and title

Parameters:spacing (int) – Spacing

See also

spacing()

QwtScaleWidget.setLabelAlignment(alignment)[source]

Change the alignment for the labels.

Parameters:spacing (int) – Spacing

See also

QwtScaleDraw.setLabelAlignment(), setLabelRotation()

QwtScaleWidget.setLabelRotation(rotation)[source]

Change the rotation for the labels.

Parameters:rotation (float) – Rotation

See also

QwtScaleDraw.setLabelRotation(), setLabelFlags()

QwtScaleWidget.setScaleDraw(scaleDraw)[source]

Set a scale draw

scaleDraw has to be created with new and will be deleted in class destructor or the next call of setScaleDraw(). scaleDraw will be initialized with the attributes of the previous scaleDraw object.

Parameters:scaleDraw (qwt.scale_draw.QwtScaleDraw) – ScaleDraw object

See also

scaleDraw()

QwtScaleWidget.scaleDraw()[source]
Returns:scaleDraw of this scale

See also

QwtScaleDraw.setScaleDraw()

QwtScaleWidget.title()[source]
Returns:title

See also

setTitle()

QwtScaleWidget.startBorderDist()[source]
Returns:start border distance

See also

setBorderDist()

QwtScaleWidget.endBorderDist()[source]
Returns:end border distance

See also

setBorderDist()

QwtScaleWidget.margin()[source]
Returns:margin

See also

setMargin()

QwtScaleWidget.spacing()[source]
Returns:distance between scale and title

See also

setSpacing()

QwtScaleWidget.draw(painter)[source]

Draw the scale

Parameters:painter (QPainter) – Painter
QwtScaleWidget.colorBarRect(rect)[source]

Calculate the the rectangle for the color bar

Parameters:rect (QRectF) – Bounding rectangle for all components of the scale
Returns:Rectangle for the color bar
QwtScaleWidget.layoutScale(update_geometry=True)[source]

Recalculate the scale’s geometry and layout based on the current geometry and fonts.

Parameters:update_geometry (bool) – Notify the layout system and call update to redraw the scale
QwtScaleWidget.drawColorBar(painter, rect)[source]

Draw the color bar of the scale widget

Parameters:
  • painter (QPainter) – Painter
  • rect (QRectF) – Bounding rectangle for the color bar
QwtScaleWidget.drawTitle(painter, align, rect)[source]

Rotate and paint a title according to its position into a given rectangle.

Parameters:
  • painter (QPainter) – Painter
  • align (int) – Alignment
  • rect (QRectF) – Bounding rectangle
QwtScaleWidget.scaleChange()[source]

Notify a change of the scale

This method can be overloaded by derived classes. The default implementation updates the geometry and repaints the widget.

QwtScaleWidget.titleHeightForWidth(width)[source]

Find the height of the title for a given width.

Parameters:width (int) – Width
Returns:Height
QwtScaleWidget.dimForLength(length, scaleFont)[source]

Find the minimum dimension for a given length. dim is the height, length the width seen in direction of the title.

Parameters:
  • length (int) – width for horizontal, height for vertical scales
  • scaleFont (QFont) – Font of the scale
Returns:

height for horizontal, width for vertical scales

QwtScaleWidget.getBorderDistHint()[source]

Calculate a hint for the border distances.

This member function calculates the distance of the scale’s endpoints from the widget borders which is required for the mark labels to fit into the widget. The maximum of this distance an the minimum border distance is returned.

Parameters:
  • start (int) – Return parameter for the border width at the beginning of the scale
  • end (int) – Return parameter for the border width at the end of the scale

Warning

The minimum border distance depends on the font.

QwtScaleWidget.setMinBorderDist(start, end)[source]

Set a minimum value for the distances of the scale’s endpoints from the widget borders. This is useful to avoid that the scales are “jumping”, when the tick labels or their positions change often.

Parameters:
  • start (int) – Minimum for the start border
  • end (int) – Minimum for the end border
QwtScaleWidget.getMinBorderDist()[source]

Get the minimum value for the distances of the scale’s endpoints from the widget borders.

Parameters:
  • start (int) – Return parameter for the border width at the beginning of the scale
  • end (int) – Return parameter for the border width at the end of the scale
QwtScaleWidget.setScaleDiv(scaleDiv)[source]

Assign a scale division

The scale division determines where to set the tick marks.

Parameters:scaleDiv (qwt.scale_div.QwtScaleDiv) – Scale Division

See also

For more information about scale divisions, see qwt.scale_div.QwtScaleDiv.

QwtScaleWidget.setTransformation(transformation)[source]

Set the transformation

Parameters:transformation (qwt.transform.Transform) – Transformation

See also

qwt.scale_draw.QwtAbstractScaleDraw.scaleDraw(), qwt.scale_map.QwtScaleMap

QwtScaleWidget.setColorBarEnabled(on)[source]

En/disable a color bar associated to the scale

Parameters:on (bool) – On/Off
QwtScaleWidget.isColorBarEnabled()[source]
Returns:True, when the color bar is enabled
QwtScaleWidget.setColorBarWidth(width)[source]

Set the width of the color bar

Parameters:width (int) – Width
QwtScaleWidget.colorBarWidth()[source]
Returns:Width of the color bar
QwtScaleWidget.colorBarInterval()[source]
Returns:Value interval for the color bar
QwtScaleWidget.setColorMap(interval, colorMap)[source]

Set the color map and value interval, that are used for displaying the color bar.

Parameters:
QwtScaleWidget.colorMap()[source]
Returns:Color map

QwtScaleDiv

class qwt.scale_div.QwtScaleDiv(*args)[source]

A class representing a scale division

A Qwt scale is defined by its boundaries and 3 list for the positions of the major, medium and minor ticks.

The upperLimit() might be smaller than the lowerLimit() to indicate inverted scales.

Scale divisions can be calculated from a QwtScaleEngine.

Scale tick types:

  • QwtScaleDiv.NoTick: No ticks
  • QwtScaleDiv.MinorTick: Minor ticks
  • QwtScaleDiv.MediumTick: Medium ticks
  • QwtScaleDiv.MajorTick: Major ticks
  • QwtScaleDiv.NTickTypes: Number of valid tick types
class QwtScaleDiv

Basic constructor. Lower bound = Upper bound = 0.

class qwt.scale_div.QwtScaleDiv(interval, ticks)[source]
Parameters:
class qwt.scale_div.QwtScaleDiv(lowerBound, upperBound)[source]
Parameters:
  • lowerBound (float) – First boundary
  • upperBound (float) – Second boundary
class qwt.scale_div.QwtScaleDiv(lowerBound, upperBound, ticks)[source]
Parameters:
  • lowerBound (float) – First boundary
  • upperBound (float) – Second boundary
  • ticks (list) – list of major, medium and minor ticks
class qwt.scale_div.QwtScaleDiv(lowerBound, upperBound, minorTicks, mediumTicks, majorTicks)[source]
Parameters:
  • lowerBound (float) – First boundary
  • upperBound (float) – Second boundary
  • minorTicks (list) – list of minor ticks
  • mediumTicks (list) – list of medium ticks
  • majorTicks (list) – list of major ticks

Note

lowerBound might be greater than upperBound for inverted scales

QwtScaleDiv.setInterval(*args)[source]

Change the interval

setInterval(lowerBound, upperBound)[source]
Parameters:
  • lowerBound (float) – First boundary
  • upperBound (float) – Second boundary
setInterval(interval)[source]
Parameters:interval (qwt.interval.QwtInterval) – Interval

Note

lowerBound might be greater than upperBound for inverted scales

QwtScaleDiv.interval()[source]
Returns:Interval
QwtScaleDiv.setLowerBound(lowerBound)[source]

Set the first boundary

Parameters:lowerBound (float) – First boundary
QwtScaleDiv.lowerBound()[source]
Returns:the first boundary

See also

upperBound()

QwtScaleDiv.setUpperBound(upperBound)[source]

Set the second boundary

Parameters:lowerBound (float) – Second boundary
QwtScaleDiv.upperBound()[source]
Returns:the second boundary

See also

lowerBound()

QwtScaleDiv.range()[source]
Returns:upperBound() - lowerBound()
QwtScaleDiv.isEmpty()[source]

Check if the scale division is empty( lowerBound() == upperBound() )

QwtScaleDiv.isIncreasing()[source]

Check if the scale division is increasing( lowerBound() <= upperBound() )

QwtScaleDiv.contains(value)[source]

Return if a value is between lowerBound() and upperBound()

Parameters:value (float) – Value
Returns:True/False
QwtScaleDiv.invert()[source]

Invert the scale division

See also

inverted()

QwtScaleDiv.inverted()[source]
Returns:A scale division with inverted boundaries and ticks

See also

invert()

QwtScaleDiv.bounded(lowerBound, upperBound)[source]

Return a scale division with an interval [lowerBound, upperBound] where all ticks outside this interval are removed

Parameters:
  • lowerBound (float) – First boundary
  • lowerBound – Second boundary
Returns:

Scale division with all ticks inside of the given interval

Note

lowerBound might be greater than upperBound for inverted scales

QwtScaleDiv.setTicks(tickType, ticks)[source]

Assign ticks

Parameters:
  • type (int) – MinorTick, MediumTick or MajorTick
  • ticks (list) – Values of the tick positions
QwtScaleDiv.ticks(tickType)[source]

Return a list of ticks

Parameters:type (int) – MinorTick, MediumTick or MajorTick
Returns:Tick list
class qwt.scale_div.QwtScaleDiv(*args)[source]

A class representing a scale division

A Qwt scale is defined by its boundaries and 3 list for the positions of the major, medium and minor ticks.

The upperLimit() might be smaller than the lowerLimit() to indicate inverted scales.

Scale divisions can be calculated from a QwtScaleEngine.

Scale tick types:

  • QwtScaleDiv.NoTick: No ticks
  • QwtScaleDiv.MinorTick: Minor ticks
  • QwtScaleDiv.MediumTick: Medium ticks
  • QwtScaleDiv.MajorTick: Major ticks
  • QwtScaleDiv.NTickTypes: Number of valid tick types
class QwtScaleDiv

Basic constructor. Lower bound = Upper bound = 0.

class qwt.scale_div.QwtScaleDiv(interval, ticks)[source]
Parameters:
class qwt.scale_div.QwtScaleDiv(lowerBound, upperBound)[source]
Parameters:
  • lowerBound (float) – First boundary
  • upperBound (float) – Second boundary
class qwt.scale_div.QwtScaleDiv(lowerBound, upperBound, ticks)[source]
Parameters:
  • lowerBound (float) – First boundary
  • upperBound (float) – Second boundary
  • ticks (list) – list of major, medium and minor ticks
class qwt.scale_div.QwtScaleDiv(lowerBound, upperBound, minorTicks, mediumTicks, majorTicks)[source]
Parameters:
  • lowerBound (float) – First boundary
  • upperBound (float) – Second boundary
  • minorTicks (list) – list of minor ticks
  • mediumTicks (list) – list of medium ticks
  • majorTicks (list) – list of major ticks

Note

lowerBound might be greater than upperBound for inverted scales

QwtScaleDiv.setInterval(*args)[source]

Change the interval

setInterval(lowerBound, upperBound)[source]
Parameters:
  • lowerBound (float) – First boundary
  • upperBound (float) – Second boundary
setInterval(interval)[source]
Parameters:interval (qwt.interval.QwtInterval) – Interval

Note

lowerBound might be greater than upperBound for inverted scales

QwtScaleDiv.interval()[source]
Returns:Interval
QwtScaleDiv.setLowerBound(lowerBound)[source]

Set the first boundary

Parameters:lowerBound (float) – First boundary
QwtScaleDiv.lowerBound()[source]
Returns:the first boundary

See also

upperBound()

QwtScaleDiv.setUpperBound(upperBound)[source]

Set the second boundary

Parameters:lowerBound (float) – Second boundary
QwtScaleDiv.upperBound()[source]
Returns:the second boundary

See also

lowerBound()

QwtScaleDiv.range()[source]
Returns:upperBound() - lowerBound()
QwtScaleDiv.isEmpty()[source]

Check if the scale division is empty( lowerBound() == upperBound() )

QwtScaleDiv.isIncreasing()[source]

Check if the scale division is increasing( lowerBound() <= upperBound() )

QwtScaleDiv.contains(value)[source]

Return if a value is between lowerBound() and upperBound()

Parameters:value (float) – Value
Returns:True/False
QwtScaleDiv.invert()[source]

Invert the scale division

See also

inverted()

QwtScaleDiv.inverted()[source]
Returns:A scale division with inverted boundaries and ticks

See also

invert()

QwtScaleDiv.bounded(lowerBound, upperBound)[source]

Return a scale division with an interval [lowerBound, upperBound] where all ticks outside this interval are removed

Parameters:
  • lowerBound (float) – First boundary
  • lowerBound – Second boundary
Returns:

Scale division with all ticks inside of the given interval

Note

lowerBound might be greater than upperBound for inverted scales

QwtScaleDiv.setTicks(tickType, ticks)[source]

Assign ticks

Parameters:
  • type (int) – MinorTick, MediumTick or MajorTick
  • ticks (list) – Values of the tick positions
QwtScaleDiv.ticks(tickType)[source]

Return a list of ticks

Parameters:type (int) – MinorTick, MediumTick or MajorTick
Returns:Tick list

QwtScaleEngine

class qwt.scale_engine.QwtScaleEngine(base=10)[source]

Base class for scale engines.

A scale engine tries to find “reasonable” ranges and step sizes for scales.

The layout of the scale can be varied with setAttribute().

python-qwt offers implementations for logarithmic and linear scales.

Layout attributes:

  • QwtScaleEngine.NoAttribute: No attributes
  • QwtScaleEngine.IncludeReference: Build a scale which includes the reference() value
  • QwtScaleEngine.Symmetric: Build a scale which is symmetric to the reference() value
  • QwtScaleEngine.Floating: The endpoints of the scale are supposed to be equal the outmost included values plus the specified margins (see setMargins()). If this attribute is not set, the endpoints of the scale will be integer multiples of the step size.
  • QwtScaleEngine.Inverted: Turn the scale upside down
autoScale(maxNumSteps, x1, x2, stepSize)[source]

Align and divide an interval

Parameters:
  • maxNumSteps (int) – Max. number of steps
  • x1 (float) – First limit of the interval (In/Out)
  • x2 (float) – Second limit of the interval (In/Out)
  • stepSize (float) – Step size
Returns:

tuple (x1, x2, stepSize)

divideScale(x1, x2, maxMajorSteps, maxMinorSteps, stepSize=0.0)[source]

Calculate a scale division

Parameters:
  • x1 (float) – First interval limit
  • x2 (float) – Second interval limit
  • maxMajorSteps (int) – Maximum for the number of major steps
  • maxMinorSteps (int) – Maximum number of minor steps
  • stepSize (float) – Step size. If stepSize == 0.0, the scaleEngine calculates one
Returns:

Calculated scale division

setTransformation(transform)[source]

Assign a transformation

Parameters:transform (qwt.transform.QwtTransform) – Transformation

The transformation object is used as factory for clones that are returned by transformation()

The scale engine takes ownership of the transformation.

See also

QwtTransform.copy(), transformation()

transformation()[source]

Create and return a clone of the transformation of the engine. When the engine has no special transformation None is returned, indicating no transformation.

Returns:A clone of the transfomation
lowerMargin()[source]
Returns:the margin at the lower end of the scale

The default margin is 0.

See also

setMargins()

upperMargin()[source]
Returns:the margin at the upper end of the scale

The default margin is 0.

See also

setMargins()

setMargins(lower, upper)[source]

Specify margins at the scale’s endpoints

Parameters:
  • lower (float) – minimum distance between the scale’s lower boundary and the smallest enclosed value
  • upper (float) – minimum distance between the scale’s upper boundary and the greatest enclosed value
Returns:

A clone of the transfomation

Margins can be used to leave a minimum amount of space between the enclosed intervals and the boundaries of the scale.

Warning

QwtLogScaleEngine measures the margins in decades.

divideInterval(intervalSize, numSteps)[source]

Calculate a step size for a given interval

Parameters:
  • intervalSize (float) – Interval size
  • numSteps (float) – Number of steps
Returns:

Step size

contains(interval, value)[source]

Check if an interval “contains” a value

Parameters:
  • intervalSize (float) – Interval size
  • value (float) – Value
Returns:

True, when the value is inside the interval

strip(ticks, interval)[source]

Remove ticks from a list, that are not inside an interval

Parameters:
Returns:

Stripped tick list

buildInterval(value)[source]

Build an interval around a value

In case of v == 0.0 the interval is [-0.5, 0.5], otherwide it is [0.5 * v, 1.5 * v]

Parameters:value (float) – Initial value
Returns:Calculated interval
setAttribute(attribute, on=True)[source]

Change a scale attribute

Parameters:
  • attribute (int) – Attribute to change
  • on (bool) – On/Off
Returns:

Calculated interval

See also

testAttribute()

testAttribute(attribute)[source]
Parameters:attribute (int) – Attribute to be tested
Returns:True, if attribute is enabled

See also

setAttribute()

setAttributes(attributes)[source]

Change the scale attribute

Parameters:attributes – Set scale attributes

See also

attributes()

attributes()[source]
Returns:Scale attributes
setReference(r)[source]

Specify a reference point

Parameters:r (float) – new reference value

The reference point is needed if options IncludeReference or Symmetric are active. Its default value is 0.0.

reference()[source]
Returns:the reference value
setBase(base)[source]

Set the base of the scale engine

While a base of 10 is what 99.9% of all applications need certain scales might need a different base: f.e 2

The default setting is 10

Parameters:base (int) – Base of the engine

See also

base()

base()[source]
Returns:Base of the scale engine

See also

setBase()

QwtLinearScaleEngine

class qwt.scale_engine.QwtLinearScaleEngine(base=10)[source]

A scale engine for linear scales

The step size will fit into the pattern

$left{ 1,2,5 ight} cdot 10^{n} $, where n is an integer.

autoScale(maxNumSteps, x1, x2, stepSize)[source]

Align and divide an interval

Parameters:
  • maxNumSteps (int) – Max. number of steps
  • x1 (float) – First limit of the interval (In/Out)
  • x2 (float) – Second limit of the interval (In/Out)
  • stepSize (float) – Step size
Returns:

tuple (x1, x2, stepSize)

See also

setAttribute()

divideScale(x1, x2, maxMajorSteps, maxMinorSteps, stepSize=0.0)[source]

Calculate a scale division for an interval

Parameters:
  • x1 (float) – First interval limit
  • x2 (float) – Second interval limit
  • maxMajorSteps (int) – Maximum for the number of major steps
  • maxMinorSteps (int) – Maximum number of minor steps
  • stepSize (float) – Step size. If stepSize == 0.0, the scaleEngine calculates one
Returns:

Calculated scale division

buildTicks(interval, stepSize, maxMinorSteps)[source]

Calculate ticks for an interval

Parameters:
  • interval (qwt.interval.QwtInterval) – Interval
  • stepSize (float) – Step size
  • maxMinorSteps (int) – Maximum number of minor steps
Returns:

Calculated ticks

buildMajorTicks(interval, stepSize)[source]

Calculate major ticks for an interval

Parameters:
Returns:

Calculated ticks

buildMinorTicks(ticks, maxMinorSteps, stepSize)[source]

Calculate minor ticks for an interval

Parameters:
  • ticks (list) – Major ticks (returned)
  • maxMinorSteps (int) – Maximum number of minor steps
  • stepSize (float) – Step size
align(interval, stepSize)[source]

Align an interval to a step size

The limits of an interval are aligned that both are integer multiples of the step size.

Parameters:
Returns:

Aligned interval

QwtLogScaleEngine

class qwt.scale_engine.QwtLogScaleEngine(base=10)[source]

A scale engine for logarithmic scales

The step size is measured in decades and the major step size will be adjusted to fit the pattern {1,2,3,5}.10**n, where n is a natural number including zero.

Warning

The step size as well as the margins are measured in decades.

autoScale(maxNumSteps, x1, x2, stepSize)[source]

Align and divide an interval

Parameters:
  • maxNumSteps (int) – Max. number of steps
  • x1 (float) – First limit of the interval (In/Out)
  • x2 (float) – Second limit of the interval (In/Out)
  • stepSize (float) – Step size
Returns:

tuple (x1, x2, stepSize)

See also

setAttribute()

divideScale(x1, x2, maxMajorSteps, maxMinorSteps, stepSize=0.0)[source]

Calculate a scale division for an interval

Parameters:
  • x1 (float) – First interval limit
  • x2 (float) – Second interval limit
  • maxMajorSteps (int) – Maximum for the number of major steps
  • maxMinorSteps (int) – Maximum number of minor steps
  • stepSize (float) – Step size. If stepSize == 0.0, the scaleEngine calculates one
Returns:

Calculated scale division

buildTicks(interval, stepSize, maxMinorSteps)[source]

Calculate ticks for an interval

Parameters:
  • interval (qwt.interval.QwtInterval) – Interval
  • stepSize (float) – Step size
  • maxMinorSteps (int) – Maximum number of minor steps
Returns:

Calculated ticks

buildMajorTicks(interval, stepSize)[source]

Calculate major ticks for an interval

Parameters:
Returns:

Calculated ticks

buildMinorTicks(ticks, maxMinorSteps, stepSize)[source]

Calculate minor ticks for an interval

Parameters:
  • ticks (list) – Major ticks (returned)
  • maxMinorSteps (int) – Maximum number of minor steps
  • stepSize (float) – Step size
align(interval, stepSize)[source]

Align an interval to a step size

The limits of an interval are aligned that both are integer multiples of the step size.

Parameters:
Returns:

Aligned interval

qwt.scale_engine.qwtStepSize(intervalSize, maxSteps, base)[source]

this version often doesn’t find the best ticks: f.e for 15: 5, 10

qwt.scale_engine.ceilEps(value, intervalSize)[source]

Ceil a value, relative to an interval

Parameters:
  • value (float) – Value to be ceiled
  • intervalSize (float) – Interval size
Returns:

Rounded value

qwt.scale_engine.floorEps(value, intervalSize)[source]

Floor a value, relative to an interval

Parameters:
  • value (float) – Value to be floored
  • intervalSize (float) – Interval size
Returns:

Rounded value

qwt.scale_engine.divideEps(intervalSize, numSteps)[source]

Divide an interval into steps

stepSize = (intervalSize - intervalSize * 10**-6) / numSteps

Parameters:
  • intervalSize (float) – Interval size
  • numSteps (float) – Number of steps
Returns:

Step size

qwt.scale_engine.divideInterval(intervalSize, numSteps, base)[source]

Calculate a step size for a given interval

Parameters:
  • intervalSize (float) – Interval size
  • numSteps (float) – Number of steps
  • base (int) – Base for the division (usually 10)
Returns:

Calculated step size

class qwt.scale_engine.QwtScaleEngine(base=10)[source]

Base class for scale engines.

A scale engine tries to find “reasonable” ranges and step sizes for scales.

The layout of the scale can be varied with setAttribute().

python-qwt offers implementations for logarithmic and linear scales.

Layout attributes:

  • QwtScaleEngine.NoAttribute: No attributes
  • QwtScaleEngine.IncludeReference: Build a scale which includes the reference() value
  • QwtScaleEngine.Symmetric: Build a scale which is symmetric to the reference() value
  • QwtScaleEngine.Floating: The endpoints of the scale are supposed to be equal the outmost included values plus the specified margins (see setMargins()). If this attribute is not set, the endpoints of the scale will be integer multiples of the step size.
  • QwtScaleEngine.Inverted: Turn the scale upside down
autoScale(maxNumSteps, x1, x2, stepSize)[source]

Align and divide an interval

Parameters:
  • maxNumSteps (int) – Max. number of steps
  • x1 (float) – First limit of the interval (In/Out)
  • x2 (float) – Second limit of the interval (In/Out)
  • stepSize (float) – Step size
Returns:

tuple (x1, x2, stepSize)

divideScale(x1, x2, maxMajorSteps, maxMinorSteps, stepSize=0.0)[source]

Calculate a scale division

Parameters:
  • x1 (float) – First interval limit
  • x2 (float) – Second interval limit
  • maxMajorSteps (int) – Maximum for the number of major steps
  • maxMinorSteps (int) – Maximum number of minor steps
  • stepSize (float) – Step size. If stepSize == 0.0, the scaleEngine calculates one
Returns:

Calculated scale division

setTransformation(transform)[source]

Assign a transformation

Parameters:transform (qwt.transform.QwtTransform) – Transformation

The transformation object is used as factory for clones that are returned by transformation()

The scale engine takes ownership of the transformation.

See also

QwtTransform.copy(), transformation()

transformation()[source]

Create and return a clone of the transformation of the engine. When the engine has no special transformation None is returned, indicating no transformation.

Returns:A clone of the transfomation
lowerMargin()[source]
Returns:the margin at the lower end of the scale

The default margin is 0.

See also

setMargins()

upperMargin()[source]
Returns:the margin at the upper end of the scale

The default margin is 0.

See also

setMargins()

setMargins(lower, upper)[source]

Specify margins at the scale’s endpoints

Parameters:
  • lower (float) – minimum distance between the scale’s lower boundary and the smallest enclosed value
  • upper (float) – minimum distance between the scale’s upper boundary and the greatest enclosed value
Returns:

A clone of the transfomation

Margins can be used to leave a minimum amount of space between the enclosed intervals and the boundaries of the scale.

Warning

QwtLogScaleEngine measures the margins in decades.

divideInterval(intervalSize, numSteps)[source]

Calculate a step size for a given interval

Parameters:
  • intervalSize (float) – Interval size
  • numSteps (float) – Number of steps
Returns:

Step size

contains(interval, value)[source]

Check if an interval “contains” a value

Parameters:
  • intervalSize (float) – Interval size
  • value (float) – Value
Returns:

True, when the value is inside the interval

strip(ticks, interval)[source]

Remove ticks from a list, that are not inside an interval

Parameters:
Returns:

Stripped tick list

buildInterval(value)[source]

Build an interval around a value

In case of v == 0.0 the interval is [-0.5, 0.5], otherwide it is [0.5 * v, 1.5 * v]

Parameters:value (float) – Initial value
Returns:Calculated interval
setAttribute(attribute, on=True)[source]

Change a scale attribute

Parameters:
  • attribute (int) – Attribute to change
  • on (bool) – On/Off
Returns:

Calculated interval

See also

testAttribute()

testAttribute(attribute)[source]
Parameters:attribute (int) – Attribute to be tested
Returns:True, if attribute is enabled

See also

setAttribute()

setAttributes(attributes)[source]

Change the scale attribute

Parameters:attributes – Set scale attributes

See also

attributes()

attributes()[source]
Returns:Scale attributes
setReference(r)[source]

Specify a reference point

Parameters:r (float) – new reference value

The reference point is needed if options IncludeReference or Symmetric are active. Its default value is 0.0.

reference()[source]
Returns:the reference value
setBase(base)[source]

Set the base of the scale engine

While a base of 10 is what 99.9% of all applications need certain scales might need a different base: f.e 2

The default setting is 10

Parameters:base (int) – Base of the engine

See also

base()

base()[source]
Returns:Base of the scale engine

See also

setBase()

class qwt.scale_engine.QwtLinearScaleEngine(base=10)[source]

A scale engine for linear scales

The step size will fit into the pattern

$left{ 1,2,5 ight} cdot 10^{n} $, where n is an integer.

autoScale(maxNumSteps, x1, x2, stepSize)[source]

Align and divide an interval

Parameters:
  • maxNumSteps (int) – Max. number of steps
  • x1 (float) – First limit of the interval (In/Out)
  • x2 (float) – Second limit of the interval (In/Out)
  • stepSize (float) – Step size
Returns:

tuple (x1, x2, stepSize)

See also

setAttribute()

divideScale(x1, x2, maxMajorSteps, maxMinorSteps, stepSize=0.0)[source]

Calculate a scale division for an interval

Parameters:
  • x1 (float) – First interval limit
  • x2 (float) – Second interval limit
  • maxMajorSteps (int) – Maximum for the number of major steps
  • maxMinorSteps (int) – Maximum number of minor steps
  • stepSize (float) – Step size. If stepSize == 0.0, the scaleEngine calculates one
Returns:

Calculated scale division

buildTicks(interval, stepSize, maxMinorSteps)[source]

Calculate ticks for an interval

Parameters:
  • interval (qwt.interval.QwtInterval) – Interval
  • stepSize (float) – Step size
  • maxMinorSteps (int) – Maximum number of minor steps
Returns:

Calculated ticks

buildMajorTicks(interval, stepSize)[source]

Calculate major ticks for an interval

Parameters:
Returns:

Calculated ticks

buildMinorTicks(ticks, maxMinorSteps, stepSize)[source]

Calculate minor ticks for an interval

Parameters:
  • ticks (list) – Major ticks (returned)
  • maxMinorSteps (int) – Maximum number of minor steps
  • stepSize (float) – Step size
align(interval, stepSize)[source]

Align an interval to a step size

The limits of an interval are aligned that both are integer multiples of the step size.

Parameters:
Returns:

Aligned interval

class qwt.scale_engine.QwtLogScaleEngine(base=10)[source]

A scale engine for logarithmic scales

The step size is measured in decades and the major step size will be adjusted to fit the pattern {1,2,3,5}.10**n, where n is a natural number including zero.

Warning

The step size as well as the margins are measured in decades.

autoScale(maxNumSteps, x1, x2, stepSize)[source]

Align and divide an interval

Parameters:
  • maxNumSteps (int) – Max. number of steps
  • x1 (float) – First limit of the interval (In/Out)
  • x2 (float) – Second limit of the interval (In/Out)
  • stepSize (float) – Step size
Returns:

tuple (x1, x2, stepSize)

See also

setAttribute()

divideScale(x1, x2, maxMajorSteps, maxMinorSteps, stepSize=0.0)[source]

Calculate a scale division for an interval

Parameters:
  • x1 (float) – First interval limit
  • x2 (float) – Second interval limit
  • maxMajorSteps (int) – Maximum for the number of major steps
  • maxMinorSteps (int) – Maximum number of minor steps
  • stepSize (float) – Step size. If stepSize == 0.0, the scaleEngine calculates one
Returns:

Calculated scale division

buildTicks(interval, stepSize, maxMinorSteps)[source]

Calculate ticks for an interval

Parameters:
  • interval (qwt.interval.QwtInterval) – Interval
  • stepSize (float) – Step size
  • maxMinorSteps (int) – Maximum number of minor steps
Returns:

Calculated ticks

buildMajorTicks(interval, stepSize)[source]

Calculate major ticks for an interval

Parameters:
Returns:

Calculated ticks

buildMinorTicks(ticks, maxMinorSteps, stepSize)[source]

Calculate minor ticks for an interval

Parameters:
  • ticks (list) – Major ticks (returned)
  • maxMinorSteps (int) – Maximum number of minor steps
  • stepSize (float) – Step size
align(interval, stepSize)[source]

Align an interval to a step size

The limits of an interval are aligned that both are integer multiples of the step size.

Parameters:
Returns:

Aligned interval

QwtAbstractScaleDraw

class qwt.scale_draw.QwtAbstractScaleDraw[source]

A abstract base class for drawing scales

QwtAbstractScaleDraw can be used to draw linear or logarithmic scales.

After a scale division has been specified as a QwtScaleDiv object using setScaleDiv(), the scale can be drawn with the draw() member.

Scale components:

  • QwtAbstractScaleDraw.Backbone: Backbone = the line where the ticks are located
  • QwtAbstractScaleDraw.Ticks: Ticks
  • QwtAbstractScaleDraw.Labels: Labels
class QwtAbstractScaleDraw

The range of the scale is initialized to [0, 100], The spacing (distance between ticks and labels) is set to 4, the tick lengths are set to 4,6 and 8 pixels

QwtAbstractScaleDraw.extent(font)[source]

Calculate the extent

The extent is the distance from the baseline to the outermost pixel of the scale draw in opposite to its orientation. It is at least minimumExtent() pixels.

Parameters:font (QFont) – Font used for drawing the tick labels
Returns:Number of pixels
QwtAbstractScaleDraw.drawTick(painter, value, len_)[source]

Draw a tick

Parameters:
  • painter (QPainter) – Painter
  • value (float) – Value of the tick
  • len (float) – Length of the tick
QwtAbstractScaleDraw.drawBackbone(painter)[source]

Draws the baseline of the scale

Parameters:painter (QPainter) – Painter
QwtAbstractScaleDraw.drawLabel(painter, value)[source]

Draws the label for a major scale tick

Parameters:
  • painter (QPainter) – Painter
  • value (float) – Value
QwtAbstractScaleDraw.enableComponent(component, enable)[source]

En/Disable a component of the scale

Parameters:
  • component (int) – Scale component
  • enable (bool) – On/Off

See also

hasComponent()

QwtAbstractScaleDraw.hasComponent(component)[source]

Check if a component is enabled

Parameters:component (int) – Component type
Returns:True, when component is enabled
QwtAbstractScaleDraw.setScaleDiv(scaleDiv)[source]

Change the scale division

Parameters:scaleDiv (qwt.scale_div.QwtScaleDiv) – New scale division
QwtAbstractScaleDraw.setTransformation(transformation)[source]

Change the transformation of the scale

Parameters:transformation (qwt.transform.QwtTransform) – New scale transformation
QwtAbstractScaleDraw.scaleMap()[source]
Returns:Map how to translate between scale and pixel values
QwtAbstractScaleDraw.scaleDiv()[source]
Returns:scale division
QwtAbstractScaleDraw.setPenWidth(width)[source]

Specify the width of the scale pen

Parameters:width (int) – Pen width

See also

penWidth()

QwtAbstractScaleDraw.penWidth()[source]
Returns:Scale pen width

See also

setPenWidth()

QwtAbstractScaleDraw.draw(painter, palette)[source]

Draw the scale

Parameters:
  • painter (QPainter) – The painter
  • palette (QPalette) – Palette, text color is used for the labels, foreground color for ticks and backbone
QwtAbstractScaleDraw.setSpacing(spacing)[source]

Set the spacing between tick and labels

The spacing is the distance between ticks and labels. The default spacing is 4 pixels.

Parameters:spacing (float) – Spacing

See also

spacing()

QwtAbstractScaleDraw.spacing()[source]

Get the spacing

The spacing is the distance between ticks and labels. The default spacing is 4 pixels.

Returns:Spacing

See also

setSpacing()

QwtAbstractScaleDraw.setMinimumExtent(minExtent)[source]

Set a minimum for the extent

The extent is calculated from the components of the scale draw. In situations, where the labels are changing and the layout depends on the extent (f.e scrolling a scale), setting an upper limit as minimum extent will avoid jumps of the layout.

Parameters:minExtent (float) – Minimum extent
QwtAbstractScaleDraw.minimumExtent()[source]

Get the minimum extent

Returns:Minimum extent
QwtAbstractScaleDraw.setTickLength(tickType, length)[source]

Set the length of the ticks

Parameters:
  • tickType (int) – Tick type
  • length (float) – New length

Warning

the length is limited to [0..1000]

QwtAbstractScaleDraw.tickLength(tickType)[source]
Returns:Length of the ticks
QwtAbstractScaleDraw.maxTickLength()[source]
Returns:Length of the longest tick

Useful for layout calculations

QwtAbstractScaleDraw.label(value)[source]

Convert a value into its representing label

The value is converted to a plain text using QLocale().toString(value). This method is often overloaded by applications to have individual labels.

Parameters:value (float) – Value
Returns:Label string
QwtAbstractScaleDraw.tickLabel(font, value)[source]

Convert a value into its representing label and cache it.

The conversion between value and label is called very often in the layout and painting code. Unfortunately the calculation of the label sizes might be slow (really slow for rich text in Qt4), so it’s necessary to cache the labels.

Parameters:
  • font (QFont) – Font
  • value (float) – Value
Returns:

Tick label

QwtAbstractScaleDraw.invalidateCache()[source]

Invalidate the cache used by tickLabel()

The cache is invalidated, when a new QwtScaleDiv is set. If the labels need to be changed. while the same QwtScaleDiv is set, invalidateCache() needs to be called manually.

QwtScaleDraw

class qwt.scale_draw.QwtScaleDraw[source]

A class for drawing scales

QwtScaleDraw can be used to draw linear or logarithmic scales. A scale has a position, an alignment and a length, which can be specified . The labels can be rotated and aligned to the ticks using setLabelRotation() and setLabelAlignment().

After a scale division has been specified as a QwtScaleDiv object using QwtAbstractScaleDraw.setScaleDiv(scaleDiv), the scale can be drawn with the QwtAbstractScaleDraw.draw() member.

Alignment of the scale draw:

  • QwtScaleDraw.BottomScale: The scale is below
  • QwtScaleDraw.TopScale: The scale is above
  • QwtScaleDraw.LeftScale: The scale is left
  • QwtScaleDraw.RightScale: The scale is right
class QwtAbstractScaleDraw

The range of the scale is initialized to [0, 100], The position is at (0, 0) with a length of 100. The orientation is QwtAbstractScaleDraw.Bottom.

QwtScaleDraw.alignment()[source]
Returns:Alignment of the scale

See also

setAlignment()

QwtScaleDraw.setAlignment(align)[source]

Set the alignment of the scale

Parameters:align (int) – Alignment of the scale

Alignment of the scale draw:

  • QwtScaleDraw.BottomScale: The scale is below
  • QwtScaleDraw.TopScale: The scale is above
  • QwtScaleDraw.LeftScale: The scale is left
  • QwtScaleDraw.RightScale: The scale is right

The default alignment is QwtScaleDraw.BottomScale

See also

alignment()

QwtScaleDraw.orientation()[source]

Return the orientation

TopScale, BottomScale are horizontal (Qt.Horizontal) scales, LeftScale, RightScale are vertical (Qt.Vertical) scales.

Returns:Orientation of the scale

See also

alignment()

QwtScaleDraw.getBorderDistHint(font)[source]

Determine the minimum border distance

This member function returns the minimum space needed to draw the mark labels at the scale’s endpoints.

Parameters:font (QFont) – Font
Returns:tuple (start, end)

Returned tuple:

  • start: Start border distance
  • end: End border distance
QwtScaleDraw.minLabelDist(font)[source]

Determine the minimum distance between two labels, that is necessary that the texts don’t overlap.

Parameters:font (QFont) – Font
Returns:The maximum width of a label
QwtScaleDraw.extent(font)[source]

Calculate the width/height that is needed for a vertical/horizontal scale.

The extent is calculated from the pen width of the backbone, the major tick length, the spacing and the maximum width/height of the labels.

Parameters:font (QFont) – Font used for painting the labels
Returns:Extent

See also

minLength()

QwtScaleDraw.minLength(font)[source]

Calculate the minimum length that is needed to draw the scale

Parameters:font (QFont) – Font used for painting the labels
Returns:Minimum length that is needed to draw the scale

See also

extent()

QwtScaleDraw.labelPosition(value)[source]

Find the position, where to paint a label

The position has a distance that depends on the length of the ticks in direction of the alignment().

Parameters:value (float) – Value
Returns:Position, where to paint a label
QwtScaleDraw.drawTick(painter, value, len_)[source]

Draw a tick

Parameters:
  • painter (QPainter) – Painter
  • value (float) – Value of the tick
  • len (float) – Length of the tick
QwtScaleDraw.drawBackbone(painter)[source]

Draws the baseline of the scale

Parameters:painter (QPainter) – Painter
QwtScaleDraw.move(*args)[source]

Move the position of the scale

The meaning of the parameter pos depends on the alignment:

  • QwtScaleDraw.LeftScale:

    The origin is the topmost point of the backbone. The backbone is a vertical line. Scale marks and labels are drawn at the left of the backbone.

  • QwtScaleDraw.RightScale:

    The origin is the topmost point of the backbone. The backbone is a vertical line. Scale marks and labels are drawn at the right of the backbone.

  • QwtScaleDraw.TopScale:

    The origin is the leftmost point of the backbone. The backbone is a horizontal line. Scale marks and labels are drawn above the backbone.

  • QwtScaleDraw.BottomScale:

    The origin is the leftmost point of the backbone. The backbone is a horizontal line Scale marks and labels are drawn below the backbone.

move(x, y)[source]
Parameters:
  • x (float) – X coordinate
  • y (float) – Y coordinate
move(pos)[source]
Parameters:pos (QPointF) – position

See also

pos(), setLength()

QwtScaleDraw.pos()[source]
Returns:Origin of the scale

See also

pos(), setLength()

QwtScaleDraw.setLength(length)[source]

Set the length of the backbone.

The length doesn’t include the space needed for overlapping labels.

Parameters:length (float) – Length of the backbone
QwtScaleDraw.length()[source]
Returns:the length of the backbone

See also

setLength(), pos()

QwtScaleDraw.drawLabel(painter, value)[source]

Draws the label for a major scale tick

Parameters:
  • painter (QPainter) – Painter
  • value (float) – Value
QwtScaleDraw.boundingLabelRect(font, value)[source]

Find the bounding rectangle for the label.

The coordinates of the rectangle are absolute (calculated from pos()) in direction of the tick.

Parameters:
  • font (QFont) – Font used for painting
  • value (float) – Value
Returns:

Bounding rectangle

See also

labelRect()

QwtScaleDraw.labelTransformation(pos, size)[source]

Calculate the transformation that is needed to paint a label depending on its alignment and rotation.

Parameters:
  • pos (QPointF) – Position where to paint the label
  • size (QSizeF) – Size of the label
Returns:

Transformation matrix

QwtScaleDraw.labelRect(font, value)[source]

Find the bounding rectangle for the label. The coordinates of the rectangle are relative to spacing + tick length from the backbone in direction of the tick.

Parameters:
  • font (QFont) – Font used for painting
  • value (float) – Value
Returns:

Bounding rectangle that is needed to draw a label

QwtScaleDraw.labelSize(font, value)[source]

Calculate the size that is needed to draw a label

Parameters:
  • font (QFont) – Label font
  • value (float) – Value
Returns:

Size that is needed to draw a label

QwtScaleDraw.setLabelRotation(rotation)[source]

Rotate all labels.

When changing the rotation, it might be necessary to adjust the label flags too. Finding a useful combination is often the result of try and error.

Parameters:rotation (float) – Angle in degrees. When changing the label rotation, the label flags often needs to be adjusted too.
QwtScaleDraw.labelRotation()[source]
Returns:the label rotation
QwtScaleDraw.setLabelAlignment(alignment)[source]

Change the label flags

Labels are aligned to the point tick length + spacing away from the backbone.

The alignment is relative to the orientation of the label text. In case of an flags of 0 the label will be aligned depending on the orientation of the scale:

  • QwtScaleDraw.TopScale: Qt.AlignHCenter | Qt.AlignTop
  • QwtScaleDraw.BottomScale: Qt.AlignHCenter | Qt.AlignBottom
  • QwtScaleDraw.LeftScale: Qt.AlignLeft | Qt.AlignVCenter
  • QwtScaleDraw.RightScale: Qt.AlignRight | Qt.AlignVCenter

Changing the alignment is often necessary for rotated labels.

:param Qt.Alignment alignment Or’d Qt.AlignmentFlags

Warning

The various alignments might be confusing. The alignment of the label is not the alignment of the scale and is not the alignment of the flags (QwtText.flags()) returned from QwtAbstractScaleDraw.label().

QwtScaleDraw.labelAlignment()[source]
Returns:the label flags
QwtScaleDraw.maxLabelWidth(font)[source]
Parameters:font (QFont) – Font
Returns:the maximum width of a label
QwtScaleDraw.maxLabelHeight(font)[source]
Parameters:font (QFont) – Font
Returns:the maximum height of a label
class qwt.scale_draw.QwtAbstractScaleDraw[source]

A abstract base class for drawing scales

QwtAbstractScaleDraw can be used to draw linear or logarithmic scales.

After a scale division has been specified as a QwtScaleDiv object using setScaleDiv(), the scale can be drawn with the draw() member.

Scale components:

  • QwtAbstractScaleDraw.Backbone: Backbone = the line where the ticks are located
  • QwtAbstractScaleDraw.Ticks: Ticks
  • QwtAbstractScaleDraw.Labels: Labels
class QwtAbstractScaleDraw

The range of the scale is initialized to [0, 100], The spacing (distance between ticks and labels) is set to 4, the tick lengths are set to 4,6 and 8 pixels

QwtAbstractScaleDraw.extent(font)[source]

Calculate the extent

The extent is the distance from the baseline to the outermost pixel of the scale draw in opposite to its orientation. It is at least minimumExtent() pixels.

Parameters:font (QFont) – Font used for drawing the tick labels
Returns:Number of pixels
QwtAbstractScaleDraw.drawTick(painter, value, len_)[source]

Draw a tick

Parameters:
  • painter (QPainter) – Painter
  • value (float) – Value of the tick
  • len (float) – Length of the tick
QwtAbstractScaleDraw.drawBackbone(painter)[source]

Draws the baseline of the scale

Parameters:painter (QPainter) – Painter
QwtAbstractScaleDraw.drawLabel(painter, value)[source]

Draws the label for a major scale tick

Parameters:
  • painter (QPainter) – Painter
  • value (float) – Value
QwtAbstractScaleDraw.enableComponent(component, enable)[source]

En/Disable a component of the scale

Parameters:
  • component (int) – Scale component
  • enable (bool) – On/Off

See also

hasComponent()

QwtAbstractScaleDraw.hasComponent(component)[source]

Check if a component is enabled

Parameters:component (int) – Component type
Returns:True, when component is enabled
QwtAbstractScaleDraw.setScaleDiv(scaleDiv)[source]

Change the scale division

Parameters:scaleDiv (qwt.scale_div.QwtScaleDiv) – New scale division
QwtAbstractScaleDraw.setTransformation(transformation)[source]

Change the transformation of the scale

Parameters:transformation (qwt.transform.QwtTransform) – New scale transformation
QwtAbstractScaleDraw.scaleMap()[source]
Returns:Map how to translate between scale and pixel values
QwtAbstractScaleDraw.scaleDiv()[source]
Returns:scale division
QwtAbstractScaleDraw.setPenWidth(width)[source]

Specify the width of the scale pen

Parameters:width (int) – Pen width

See also

penWidth()

QwtAbstractScaleDraw.penWidth()[source]
Returns:Scale pen width

See also

setPenWidth()

QwtAbstractScaleDraw.draw(painter, palette)[source]

Draw the scale

Parameters:
  • painter (QPainter) – The painter
  • palette (QPalette) – Palette, text color is used for the labels, foreground color for ticks and backbone
QwtAbstractScaleDraw.setSpacing(spacing)[source]

Set the spacing between tick and labels

The spacing is the distance between ticks and labels. The default spacing is 4 pixels.

Parameters:spacing (float) – Spacing

See also

spacing()

QwtAbstractScaleDraw.spacing()[source]

Get the spacing

The spacing is the distance between ticks and labels. The default spacing is 4 pixels.

Returns:Spacing

See also

setSpacing()

QwtAbstractScaleDraw.setMinimumExtent(minExtent)[source]

Set a minimum for the extent

The extent is calculated from the components of the scale draw. In situations, where the labels are changing and the layout depends on the extent (f.e scrolling a scale), setting an upper limit as minimum extent will avoid jumps of the layout.

Parameters:minExtent (float) – Minimum extent
QwtAbstractScaleDraw.minimumExtent()[source]

Get the minimum extent

Returns:Minimum extent
QwtAbstractScaleDraw.setTickLength(tickType, length)[source]

Set the length of the ticks

Parameters:
  • tickType (int) – Tick type
  • length (float) – New length

Warning

the length is limited to [0..1000]

QwtAbstractScaleDraw.tickLength(tickType)[source]
Returns:Length of the ticks
QwtAbstractScaleDraw.maxTickLength()[source]
Returns:Length of the longest tick

Useful for layout calculations

QwtAbstractScaleDraw.label(value)[source]

Convert a value into its representing label

The value is converted to a plain text using QLocale().toString(value). This method is often overloaded by applications to have individual labels.

Parameters:value (float) – Value
Returns:Label string
QwtAbstractScaleDraw.tickLabel(font, value)[source]

Convert a value into its representing label and cache it.

The conversion between value and label is called very often in the layout and painting code. Unfortunately the calculation of the label sizes might be slow (really slow for rich text in Qt4), so it’s necessary to cache the labels.

Parameters:
  • font (QFont) – Font
  • value (float) – Value
Returns:

Tick label

QwtAbstractScaleDraw.invalidateCache()[source]

Invalidate the cache used by tickLabel()

The cache is invalidated, when a new QwtScaleDiv is set. If the labels need to be changed. while the same QwtScaleDiv is set, invalidateCache() needs to be called manually.

class qwt.scale_draw.QwtScaleDraw[source]

A class for drawing scales

QwtScaleDraw can be used to draw linear or logarithmic scales. A scale has a position, an alignment and a length, which can be specified . The labels can be rotated and aligned to the ticks using setLabelRotation() and setLabelAlignment().

After a scale division has been specified as a QwtScaleDiv object using QwtAbstractScaleDraw.setScaleDiv(scaleDiv), the scale can be drawn with the QwtAbstractScaleDraw.draw() member.

Alignment of the scale draw:

  • QwtScaleDraw.BottomScale: The scale is below
  • QwtScaleDraw.TopScale: The scale is above
  • QwtScaleDraw.LeftScale: The scale is left
  • QwtScaleDraw.RightScale: The scale is right
class QwtAbstractScaleDraw

The range of the scale is initialized to [0, 100], The position is at (0, 0) with a length of 100. The orientation is QwtAbstractScaleDraw.Bottom.

QwtScaleDraw.alignment()[source]
Returns:Alignment of the scale

See also

setAlignment()

QwtScaleDraw.setAlignment(align)[source]

Set the alignment of the scale

Parameters:align (int) – Alignment of the scale

Alignment of the scale draw:

  • QwtScaleDraw.BottomScale: The scale is below
  • QwtScaleDraw.TopScale: The scale is above
  • QwtScaleDraw.LeftScale: The scale is left
  • QwtScaleDraw.RightScale: The scale is right

The default alignment is QwtScaleDraw.BottomScale

See also

alignment()

QwtScaleDraw.orientation()[source]

Return the orientation

TopScale, BottomScale are horizontal (Qt.Horizontal) scales, LeftScale, RightScale are vertical (Qt.Vertical) scales.

Returns:Orientation of the scale

See also

alignment()

QwtScaleDraw.getBorderDistHint(font)[source]

Determine the minimum border distance

This member function returns the minimum space needed to draw the mark labels at the scale’s endpoints.

Parameters:font (QFont) – Font
Returns:tuple (start, end)

Returned tuple:

  • start: Start border distance
  • end: End border distance
QwtScaleDraw.minLabelDist(font)[source]

Determine the minimum distance between two labels, that is necessary that the texts don’t overlap.

Parameters:font (QFont) – Font
Returns:The maximum width of a label
QwtScaleDraw.extent(font)[source]

Calculate the width/height that is needed for a vertical/horizontal scale.

The extent is calculated from the pen width of the backbone, the major tick length, the spacing and the maximum width/height of the labels.

Parameters:font (QFont) – Font used for painting the labels
Returns:Extent

See also

minLength()

QwtScaleDraw.minLength(font)[source]

Calculate the minimum length that is needed to draw the scale

Parameters:font (QFont) – Font used for painting the labels
Returns:Minimum length that is needed to draw the scale

See also

extent()

QwtScaleDraw.labelPosition(value)[source]

Find the position, where to paint a label

The position has a distance that depends on the length of the ticks in direction of the alignment().

Parameters:value (float) – Value
Returns:Position, where to paint a label
QwtScaleDraw.drawTick(painter, value, len_)[source]

Draw a tick

Parameters:
  • painter (QPainter) – Painter
  • value (float) – Value of the tick
  • len (float) – Length of the tick
QwtScaleDraw.drawBackbone(painter)[source]

Draws the baseline of the scale

Parameters:painter (QPainter) – Painter
QwtScaleDraw.move(*args)[source]

Move the position of the scale

The meaning of the parameter pos depends on the alignment:

  • QwtScaleDraw.LeftScale:

    The origin is the topmost point of the backbone. The backbone is a vertical line. Scale marks and labels are drawn at the left of the backbone.

  • QwtScaleDraw.RightScale:

    The origin is the topmost point of the backbone. The backbone is a vertical line. Scale marks and labels are drawn at the right of the backbone.

  • QwtScaleDraw.TopScale:

    The origin is the leftmost point of the backbone. The backbone is a horizontal line. Scale marks and labels are drawn above the backbone.

  • QwtScaleDraw.BottomScale:

    The origin is the leftmost point of the backbone. The backbone is a horizontal line Scale marks and labels are drawn below the backbone.

move(x, y)[source]
Parameters:
  • x (float) – X coordinate
  • y (float) – Y coordinate
move(pos)[source]
Parameters:pos (QPointF) – position

See also

pos(), setLength()

QwtScaleDraw.pos()[source]
Returns:Origin of the scale

See also

pos(), setLength()

QwtScaleDraw.setLength(length)[source]

Set the length of the backbone.

The length doesn’t include the space needed for overlapping labels.

Parameters:length (float) – Length of the backbone
QwtScaleDraw.length()[source]
Returns:the length of the backbone

See also

setLength(), pos()

QwtScaleDraw.drawLabel(painter, value)[source]

Draws the label for a major scale tick

Parameters:
  • painter (QPainter) – Painter
  • value (float) – Value
QwtScaleDraw.boundingLabelRect(font, value)[source]

Find the bounding rectangle for the label.

The coordinates of the rectangle are absolute (calculated from pos()) in direction of the tick.

Parameters:
  • font (QFont) – Font used for painting
  • value (float) – Value
Returns:

Bounding rectangle

See also

labelRect()

QwtScaleDraw.labelTransformation(pos, size)[source]

Calculate the transformation that is needed to paint a label depending on its alignment and rotation.

Parameters:
  • pos (QPointF) – Position where to paint the label
  • size (QSizeF) – Size of the label
Returns:

Transformation matrix

QwtScaleDraw.labelRect(font, value)[source]

Find the bounding rectangle for the label. The coordinates of the rectangle are relative to spacing + tick length from the backbone in direction of the tick.

Parameters:
  • font (QFont) – Font used for painting
  • value (float) – Value
Returns:

Bounding rectangle that is needed to draw a label

QwtScaleDraw.labelSize(font, value)[source]

Calculate the size that is needed to draw a label

Parameters:
  • font (QFont) – Label font
  • value (float) – Value
Returns:

Size that is needed to draw a label

QwtScaleDraw.setLabelRotation(rotation)[source]

Rotate all labels.

When changing the rotation, it might be necessary to adjust the label flags too. Finding a useful combination is often the result of try and error.

Parameters:rotation (float) – Angle in degrees. When changing the label rotation, the label flags often needs to be adjusted too.
QwtScaleDraw.labelRotation()[source]
Returns:the label rotation
QwtScaleDraw.setLabelAlignment(alignment)[source]

Change the label flags

Labels are aligned to the point tick length + spacing away from the backbone.

The alignment is relative to the orientation of the label text. In case of an flags of 0 the label will be aligned depending on the orientation of the scale:

  • QwtScaleDraw.TopScale: Qt.AlignHCenter | Qt.AlignTop
  • QwtScaleDraw.BottomScale: Qt.AlignHCenter | Qt.AlignBottom
  • QwtScaleDraw.LeftScale: Qt.AlignLeft | Qt.AlignVCenter
  • QwtScaleDraw.RightScale: Qt.AlignRight | Qt.AlignVCenter

Changing the alignment is often necessary for rotated labels.

:param Qt.Alignment alignment Or’d Qt.AlignmentFlags

Warning

The various alignments might be confusing. The alignment of the label is not the alignment of the scale and is not the alignment of the flags (QwtText.flags()) returned from QwtAbstractScaleDraw.label().

QwtScaleDraw.labelAlignment()[source]
Returns:the label flags
QwtScaleDraw.maxLabelWidth(font)[source]
Parameters:font (QFont) – Font
Returns:the maximum width of a label
QwtScaleDraw.maxLabelHeight(font)[source]
Parameters:font (QFont) – Font
Returns:the maximum height of a label