# QwtPlotLayout

class qwt.plot_layout.QwtPlotLayout

  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.

  See also

  `qwt.plot.QwtPlot.setPlotLayout()`

  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)

    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)
    Parameters:

      axisId (int) – Axis index

    Returns:

      Margin around the scale tick borders

    See also

    `setCanvasMargin()`

  setAlignCanvasToScales(*args)

    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)

    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)

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

    Parameters:

      spacing (int) – New spacing

    See also

    `setCanvasMargin()`, `spacing()`

  spacing()
    Returns:

      Spacing

    See also

    `margin()`, `setSpacing()`

  setLegendPosition(*args)

    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

    See also

    `setLegendPosition()`

  legendPosition()
    Returns:

      Position of the legend

    See also

    `legendPosition()`

  setLegendRatio(ratio)

    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()
    Returns:

      The relative size of the legend in the plot.

    See also

    `setLegendRatio()`

  setTitleRect(rect)

    Set the geometry for the title

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

    Parameters:

      rect (QRectF) – Rectangle

    See also

    `titleRect()`, `activate()`

  titleRect()
    Returns:

      Geometry for the title

    See also

    `invalidate()`, `activate()`

  setFooterRect(rect)

    Set the geometry for the footer

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

    Parameters:

      rect (QRectF) – Rectangle

    See also

    `footerRect()`, `activate()`

  footerRect()
    Returns:

      Geometry for the footer

    See also

    `invalidate()`, `activate()`

  setLegendRect(rect)

    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

    See also

    `footerRect()`, `activate()`

  legendRect()
    Returns:

      Geometry for the legend

    See also

    `invalidate()`, `activate()`

  setScaleRect(axis, rect)

    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

    See also

    `scaleRect()`, `activate()`

  scaleRect(axis)
    Parameters:

      axisId (int) – Axis index

    Returns:

      Geometry for the scale

    See also

    `invalidate()`, `activate()`

  setCanvasRect(rect)

    Set the geometry for the canvas

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

    Parameters:

      rect (QRectF) – Rectangle

    See also

    `canvasRect()`, `activate()`

  canvasRect()
    Returns:

      Geometry for the canvas

    See also

    `invalidate()`, `activate()`

  invalidate()

    Invalidate the geometry of all components.

    See also

    `activate()`

  minimumSizeHint(plot)
    Parameters:

      plot (qwt.plot.QwtPlot) – Plot widget

    Returns:

      Minimum size hint

    See also

    `qwt.plot.QwtPlot.minimumSizeHint()`

  layoutLegend(options, rect)

    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)

    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)

    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, dimAxes)

    Returns:

    > - dimTitle: Expanded height of the title widget

    > - dimFooter: Expanded height of the footer widget

    > - dimAxes: Expanded heights of the axis in axis orientation.

  alignScales(options, canvasRect, scaleRect)

    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)

    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