QwtPlotLayout

class qwt.plot_layout.QwtPlotLayout[source]

Layout engine for QwtPlot.

It is used by the QwtPlot widget to organize its internal widgets or by QwtPlot.print() to render its content to a QPaintDevice like a QPrinter, QPixmap/QImage or QSvgRenderer.

Valid options:

  • QwtPlotLayout.AlignScales: Unused
  • QwtPlotLayout.IgnoreScrollbars: Ignore the dimension of the scrollbars. There are no scrollbars, when the plot is not rendered to widgets.
  • QwtPlotLayout.IgnoreFrames: Ignore all frames.
  • QwtPlotLayout.IgnoreLegend: Ignore the legend.
  • QwtPlotLayout.IgnoreTitle: Ignore the title.
  • QwtPlotLayout.IgnoreFooter: Ignore the footer.
setCanvasMargin(margin, axis=-1)[source]

Change a margin of the canvas. The margin is the space above/below the scale ticks. A negative margin will be set to -1, excluding the borders of the scales.

Parameters:
  • margin (int) – New margin
  • axisId (int) – Axis index

See also

canvasMargin()

Warning

The margin will have no effect when alignCanvasToScale() is True

canvasMargin(axisId)[source]
Parameters:axisId (int) – Axis index
Returns:Margin around the scale tick borders
setAlignCanvasToScales(*args)[source]

Change the align-canvas-to-axis-scales setting.

setAlignCanvasToScales(on):

Set the align-canvas-to-axis-scales flag for all axes

Parameters:on (bool) – True/False
setAlignCanvasToScales(axisId, on):

Change the align-canvas-to-axis-scales setting. The canvas may:

  • extend beyond the axis scale ends to maximize its size,
  • align with the axis scale ends to control its size.

The axisId parameter is somehow confusing as it identifies a border of the plot and not the axes, that are aligned. F.e when QwtPlot.yLeft is set, the left end of the the x-axes (QwtPlot.xTop, QwtPlot.xBottom) is aligned.

Parameters:
  • axisId (int) – Axis index
  • on (bool) – True/False

See also

setAlignCanvasToScale(), alignCanvasToScale()

alignCanvasToScale(axisId)[source]

Return the align-canvas-to-axis-scales setting. The canvas may:

  • extend beyond the axis scale ends to maximize its size
  • align with the axis scale ends to control its size.
Parameters:axisId (int) – Axis index
Returns:align-canvas-to-axis-scales setting

See also

setAlignCanvasToScale(), setCanvasMargin()

setSpacing(spacing)[source]

Change the spacing of the plot. The spacing is the distance between the plot components.

Parameters:spacing (int) – New spacing
spacing()[source]
Returns:Spacing

See also

margin(), setSpacing()

setLegendPosition(*args)[source]

Specify the position of the legend

setLegendPosition(pos, [ratio=0.]):

Specify the position of the legend

Parameters:
  • pos (QwtPlot.LegendPosition) – Legend position
  • ratio (float) – Ratio between legend and the bounding rectangle of title, footer, canvas and axes

The legend will be shrunk if it would need more space than the given ratio. The ratio is limited to ]0.0 .. 1.0]. In case of <= 0.0 it will be reset to the default ratio. The default vertical/horizontal ratio is 0.33/0.5.

Valid position values:

  • QwtPlot.LeftLegend,
  • QwtPlot.RightLegend,
  • QwtPlot.TopLegend,
  • QwtPlot.BottomLegend
legendPosition()[source]
Returns:Position of the legend

See also

legendPosition()

setLegendRatio(ratio)[source]

Specify the relative size of the legend in the plot

Parameters:ratio (float) – Ratio between legend and the bounding rectangle of title, footer, canvas and axes

The legend will be shrunk if it would need more space than the given ratio. The ratio is limited to ]0.0 .. 1.0]. In case of <= 0.0 it will be reset to the default ratio. The default vertical/horizontal ratio is 0.33/0.5.

See also

legendRatio()

legendRatio()[source]
Returns:The relative size of the legend in the plot.

See also

setLegendRatio()

setTitleRect(rect)[source]

Set the geometry for the title

This method is intended to be used from derived layouts overloading activate()

Parameters:rect (QRectF) – Rectangle
titleRect()[source]
Returns:Geometry for the title
setFooterRect(rect)[source]

Set the geometry for the footer

This method is intended to be used from derived layouts overloading activate()

Parameters:rect (QRectF) – Rectangle
footerRect()[source]
Returns:Geometry for the footer
setLegendRect(rect)[source]

Set the geometry for the legend

This method is intended to be used from derived layouts overloading activate()

Parameters:rect (QRectF) – Rectangle for the legend
legendRect()[source]
Returns:Geometry for the legend
setScaleRect(axis, rect)[source]

Set the geometry for an axis

This method is intended to be used from derived layouts overloading activate()

Parameters:
  • axisId (int) – Axis index
  • rect (QRectF) – Rectangle for the scale
scaleRect(axis)[source]
Parameters:axisId (int) – Axis index
Returns:Geometry for the scale
setCanvasRect(rect)[source]

Set the geometry for the canvas

This method is intended to be used from derived layouts overloading activate()

Parameters:rect (QRectF) – Rectangle
canvasRect()[source]
Returns:Geometry for the canvas
invalidate()[source]

Invalidate the geometry of all components.

See also

activate()

minimumSizeHint(plot)[source]
Parameters:plot (qwt.plot.QwtPlot) – Plot widget
Returns:Minimum size hint
layoutLegend(options, rect)[source]

Find the geometry for the legend

Parameters:
  • options – Options how to layout the legend
  • rect (QRectF) – Rectangle where to place the legend
Returns:

Geometry for the legend

alignLegend(canvasRect, legendRect)[source]

Align the legend to the canvas

Parameters:
  • canvasRect (QRectF) – Geometry of the canvas
  • legendRect (QRectF) – Maximum geometry for the legend
Returns:

Geometry for the aligned legend

expandLineBreaks(options, rect)[source]

Expand all line breaks in text labels, and calculate the height of their widgets in orientation of the text.

Parameters:
  • options – Options how to layout the legend
  • rect (QRectF) – Bounding rectangle for title, footer, axes and canvas.
Returns:

tuple (dimTitle, dimFooter, dimAxis)

Returns:

  • dimTitle: Expanded height of the title widget
  • dimFooter: Expanded height of the footer widget
  • dimAxis: Expanded heights of the axis in axis orientation.
alignScales(options, canvasRect, scaleRect)[source]

Align the ticks of the axis to the canvas borders using the empty corners.

Parameters:
  • options – Options how to layout the legend
  • canvasRect (QRectF) – Geometry of the canvas ( IN/OUT )
  • scaleRect (QRectF) – Geometry of the scales ( IN/OUT )
activate(plot, plotRect, options=0)[source]

Recalculate the geometry of all components.

Parameters:
  • plot (qwt.plot.QwtPlot) – Plot to be layout
  • plotRect (QRectF) – Rectangle where to place the components
  • options – Layout options
class qwt.plot_layout.QwtPlotLayout[source]

Layout engine for QwtPlot.

It is used by the QwtPlot widget to organize its internal widgets or by QwtPlot.print() to render its content to a QPaintDevice like a QPrinter, QPixmap/QImage or QSvgRenderer.

Valid options:

  • QwtPlotLayout.AlignScales: Unused
  • QwtPlotLayout.IgnoreScrollbars: Ignore the dimension of the scrollbars. There are no scrollbars, when the plot is not rendered to widgets.
  • QwtPlotLayout.IgnoreFrames: Ignore all frames.
  • QwtPlotLayout.IgnoreLegend: Ignore the legend.
  • QwtPlotLayout.IgnoreTitle: Ignore the title.
  • QwtPlotLayout.IgnoreFooter: Ignore the footer.
setCanvasMargin(margin, axis=-1)[source]

Change a margin of the canvas. The margin is the space above/below the scale ticks. A negative margin will be set to -1, excluding the borders of the scales.

Parameters:
  • margin (int) – New margin
  • axisId (int) – Axis index

See also

canvasMargin()

Warning

The margin will have no effect when alignCanvasToScale() is True

canvasMargin(axisId)[source]
Parameters:axisId (int) – Axis index
Returns:Margin around the scale tick borders
setAlignCanvasToScales(*args)[source]

Change the align-canvas-to-axis-scales setting.

setAlignCanvasToScales(on):

Set the align-canvas-to-axis-scales flag for all axes

Parameters:on (bool) – True/False
setAlignCanvasToScales(axisId, on):

Change the align-canvas-to-axis-scales setting. The canvas may:

  • extend beyond the axis scale ends to maximize its size,
  • align with the axis scale ends to control its size.

The axisId parameter is somehow confusing as it identifies a border of the plot and not the axes, that are aligned. F.e when QwtPlot.yLeft is set, the left end of the the x-axes (QwtPlot.xTop, QwtPlot.xBottom) is aligned.

Parameters:
  • axisId (int) – Axis index
  • on (bool) – True/False

See also

setAlignCanvasToScale(), alignCanvasToScale()

alignCanvasToScale(axisId)[source]

Return the align-canvas-to-axis-scales setting. The canvas may:

  • extend beyond the axis scale ends to maximize its size
  • align with the axis scale ends to control its size.
Parameters:axisId (int) – Axis index
Returns:align-canvas-to-axis-scales setting

See also

setAlignCanvasToScale(), setCanvasMargin()

setSpacing(spacing)[source]

Change the spacing of the plot. The spacing is the distance between the plot components.

Parameters:spacing (int) – New spacing
spacing()[source]
Returns:Spacing

See also

margin(), setSpacing()

setLegendPosition(*args)[source]

Specify the position of the legend

setLegendPosition(pos, [ratio=0.]):

Specify the position of the legend

Parameters:
  • pos (QwtPlot.LegendPosition) – Legend position
  • ratio (float) – Ratio between legend and the bounding rectangle of title, footer, canvas and axes

The legend will be shrunk if it would need more space than the given ratio. The ratio is limited to ]0.0 .. 1.0]. In case of <= 0.0 it will be reset to the default ratio. The default vertical/horizontal ratio is 0.33/0.5.

Valid position values:

  • QwtPlot.LeftLegend,
  • QwtPlot.RightLegend,
  • QwtPlot.TopLegend,
  • QwtPlot.BottomLegend
legendPosition()[source]
Returns:Position of the legend

See also

legendPosition()

setLegendRatio(ratio)[source]

Specify the relative size of the legend in the plot

Parameters:ratio (float) – Ratio between legend and the bounding rectangle of title, footer, canvas and axes

The legend will be shrunk if it would need more space than the given ratio. The ratio is limited to ]0.0 .. 1.0]. In case of <= 0.0 it will be reset to the default ratio. The default vertical/horizontal ratio is 0.33/0.5.

See also

legendRatio()

legendRatio()[source]
Returns:The relative size of the legend in the plot.

See also

setLegendRatio()

setTitleRect(rect)[source]

Set the geometry for the title

This method is intended to be used from derived layouts overloading activate()

Parameters:rect (QRectF) – Rectangle
titleRect()[source]
Returns:Geometry for the title
setFooterRect(rect)[source]

Set the geometry for the footer

This method is intended to be used from derived layouts overloading activate()

Parameters:rect (QRectF) – Rectangle
footerRect()[source]
Returns:Geometry for the footer
setLegendRect(rect)[source]

Set the geometry for the legend

This method is intended to be used from derived layouts overloading activate()

Parameters:rect (QRectF) – Rectangle for the legend
legendRect()[source]
Returns:Geometry for the legend
setScaleRect(axis, rect)[source]

Set the geometry for an axis

This method is intended to be used from derived layouts overloading activate()

Parameters:
  • axisId (int) – Axis index
  • rect (QRectF) – Rectangle for the scale
scaleRect(axis)[source]
Parameters:axisId (int) – Axis index
Returns:Geometry for the scale
setCanvasRect(rect)[source]

Set the geometry for the canvas

This method is intended to be used from derived layouts overloading activate()

Parameters:rect (QRectF) – Rectangle
canvasRect()[source]
Returns:Geometry for the canvas
invalidate()[source]

Invalidate the geometry of all components.

See also

activate()

minimumSizeHint(plot)[source]
Parameters:plot (qwt.plot.QwtPlot) – Plot widget
Returns:Minimum size hint
layoutLegend(options, rect)[source]

Find the geometry for the legend

Parameters:
  • options – Options how to layout the legend
  • rect (QRectF) – Rectangle where to place the legend
Returns:

Geometry for the legend

alignLegend(canvasRect, legendRect)[source]

Align the legend to the canvas

Parameters:
  • canvasRect (QRectF) – Geometry of the canvas
  • legendRect (QRectF) – Maximum geometry for the legend
Returns:

Geometry for the aligned legend

expandLineBreaks(options, rect)[source]

Expand all line breaks in text labels, and calculate the height of their widgets in orientation of the text.

Parameters:
  • options – Options how to layout the legend
  • rect (QRectF) – Bounding rectangle for title, footer, axes and canvas.
Returns:

tuple (dimTitle, dimFooter, dimAxis)

Returns:

  • dimTitle: Expanded height of the title widget
  • dimFooter: Expanded height of the footer widget
  • dimAxis: Expanded heights of the axis in axis orientation.
alignScales(options, canvasRect, scaleRect)[source]

Align the ticks of the axis to the canvas borders using the empty corners.

Parameters:
  • options – Options how to layout the legend
  • canvasRect (QRectF) – Geometry of the canvas ( IN/OUT )
  • scaleRect (QRectF) – Geometry of the scales ( IN/OUT )
activate(plot, plotRect, options=0)[source]

Recalculate the geometry of all components.

Parameters:
  • plot (qwt.plot.QwtPlot) – Plot to be layout
  • plotRect (QRectF) – Rectangle where to place the components
  • options – Layout options