# geom

Geometric primitives for plots.

Classes:

 `Point`([color, size]) A simple point. `Line`([color, size]) A simple line `Segment`(**kwargs) A line segment that draws from 0.5 to some endpoint. `Roll_Mean` Shaded area underneath a rolling average. `Shaded`(**kwargs) Shaded area for a continuous plot A Horizontal line.

Data:

 `PLOT_LIST` A dictionary connecting plot keys to objects.
class Point(color=(0, 0, 0), size=5, **kwargs)[source]

A simple point.

Variables
• brush (`QtWidgets.QBrush`) –

• pen (`QtWidgets.QPen`) –

Parameters
• color (tuple) – RGB color of points

• size (int) – width in px.

Methods:

 `update`(data) Parameters data (`numpy.ndarray`) -- an x_width x 2 array where

Attributes:

update(data)[source]
Parameters

data (`numpy.ndarray`) – an x_width x 2 array where column 0 is trial number and column 1 is the value, where value can be “L”, “C”, “R” or a float.

staticMetaObject = <PySide2.QtCore.QMetaObject object at 0x7f4179a2f740>
class Line(color=(0, 0, 0), size=1, **kwargs)[source]

A simple line

There are many different ways to create a PlotDataItem.

Data initialization arguments: (x,y data only)

 PlotDataItem(x, y) x, y: array_like coordinate values PlotDataItem(y) y values only – x will be automatically set to `range(len(y))` PlotDataItem(x=x, y=y) x and y given by keyword arguments PlotDataItem(ndarray(N,2)) single numpy array with shape (N, 2), where `x=data[:,0]` and `y=data[:,1]`

Data initialization arguments: (x,y data AND may include spot style)

 PlotDataItem(recarray) numpy record array with ```dtype=[('x', float), ('y', float), ...]``` PlotDataItem(list-of-dicts) `[{'x': x, 'y': y, ...},   ...]` PlotDataItem(dict-of-lists) `{'x': [...], 'y': [...],  ...}`

Line style keyword arguments:

 connect Specifies how / whether vertexes should be connected. See below for details. pen Pen to use for drawing the lines between points. Default is solid grey, 1px width. Use None to disable line drawing. May be a `QPen` or any single argument accepted by `mkPen()` shadowPen Pen for secondary line to draw behind the primary line. Disabled by default. May be a `QPen` or any single argument accepted by `mkPen()` fillLevel If specified, the area between the curve and fillLevel is filled. fillOutline (bool) If True, an outline surrounding the fillLevel area is drawn. fillBrush Fill to use in the fillLevel area. May be any single argument accepted by `mkBrush()` stepMode (str or None) If specified and not None, a stepped curve is drawn. For ‘left’ the specified points each describe the left edge of a step. For ‘right’, they describe the right edge. For ‘center’, the x coordinates specify the location of the step boundaries. This mode is commonly used for histograms. Note that it requires an additional x value, such that len(x) = len(y) + 1 .

`connect` supports the following arguments:

• ‘all’ connects all points.

• ‘pairs’ generates lines between every other point.

• ‘finite’ creates a break when a nonfinite points is encountered.

• If an ndarray is passed, it should contain N int32 values of 0 or 1. Values of 1 indicate that the respective point will be connected to the next.

• In the default ‘auto’ mode, PlotDataItem will normally use ‘all’, but if any nonfinite data points are detected, it will automatically switch to ‘finite’.

See `arrayToQPath()` for more details.

Point style keyword arguments: (see `ScatterPlotItem.setData()` for more information)

 symbol Symbol to use for drawing points, or a list of symbols for each. The default is no symbol. symbolPen Outline pen for drawing points, or a list of pens, one per point. May be any single argument accepted by `mkPen()`. symbolBrush Brush for filling points, or a list of brushes, one per point. May be any single argument accepted by `mkBrush()`. symbolSize Diameter of symbols, or list of diameters. pxMode (bool) If True, then symbolSize is specified in pixels. If False, then symbolSize is specified in data coordinates.

Any symbol recognized by `ScatterPlotItem` can be specified, including ‘o’ (circle), ‘s’ (square), ‘t’, ‘t1’, ‘t2’, ‘t3’ (triangles of different orientation), ‘d’ (diamond), ‘+’ (plus sign), ‘x’ (x mark), ‘p’ (pentagon), ‘h’ (hexagon) and ‘star’.

Symbols can also be directly given in the form of a `QtGui.QPainterPath` instance.

Optimization keyword arguments:

 antialias (bool) By default, antialiasing is disabled to improve performance. Note that in some cases (in particular, when `pxMode=True`), points will be rendered antialiased even if this is set to False. downsample (int) Reduce the number of samples displayed by the given factor. downsampleMethod ‘subsample’: Downsample by taking the first of N samples. This method is fastest and least accurate. ‘mean’: Downsample by taking the mean of N samples. ‘peak’: Downsample by drawing a saw wave that follows the min and max of the original data. This method produces the best visual representation of the data but is slower. autoDownsample (bool) If True, resample the data before plotting to avoid plotting multiple line segments per pixel. This can improve performance when viewing very high-density data, but increases the initial overhead and memory usage. clipToView (bool) If True, only data visible within the X range of the containing `ViewBox` is plotted. This can improve performance when plotting very large data sets where only a fraction of the data is visible at any time. dynamicRangeLimit (float or None) Limit off-screen y positions of data points. None disables the limiting. This can increase performance but may cause plots to disappear at high levels of magnification. The default of 1e6 limits data to approximately 1,000,000 times the `ViewBox` height. dynamicRangeHyst (float) Permits changes in vertical zoom up to the given hysteresis factor (the default is 3.0) before the limit calculation is repeated. skipFiniteCheck (bool, default False) Optimization flag that can speed up plotting by not checking and compensating for NaN values. If set to True, and NaN values exist, unpredictable behavior will occur. The data may not be displayed or the plot may take a significant performance hit. In the default ‘auto’ connect mode, PlotDataItem will apply this setting automatically.

Meta-info keyword arguments:

 name (string) Name of item for use in the plot legend

Notes on performance:

Plotting lines with the default single-pixel width is the fastest available option. For such lines, translucent colors (alpha < 1) do not result in a significant slowdown.

Wider lines increase the complexity due to the overlap of individual line segments. Translucent colors require merging the entire plot into a single entity before the alpha value can be applied. For plots with more than a few hundred points, this can result in excessive slowdown.

Since version 0.12.4, this slowdown is automatically avoided by an algorithm that draws line segments separately for fully opaque lines. Setting alpha < 1 reverts to the previous, slower drawing method.

For lines with a width of more than 4 pixels, `pyqtgraph.mkPen()` will automatically create a `QPen` with Qt.PenCapStyle.RoundCap to ensure a smooth connection of line segments. This incurs a small performance penalty.

Methods:

 `update`() -> None)

Attributes:

update(self, rect: PySide2.QtCore.QRectF = Default(QRectF)) None[source]
update(self, x: float, y: float, width: float, height: float) None
staticMetaObject = <PySide2.QtCore.QMetaObject object at 0x7f4179a2fa00>
class Segment(**kwargs)[source]

A line segment that draws from 0.5 to some endpoint.

There are many different ways to create a PlotDataItem.

Data initialization arguments: (x,y data only)

 PlotDataItem(x, y) x, y: array_like coordinate values PlotDataItem(y) y values only – x will be automatically set to `range(len(y))` PlotDataItem(x=x, y=y) x and y given by keyword arguments PlotDataItem(ndarray(N,2)) single numpy array with shape (N, 2), where `x=data[:,0]` and `y=data[:,1]`

Data initialization arguments: (x,y data AND may include spot style)

 PlotDataItem(recarray) numpy record array with ```dtype=[('x', float), ('y', float), ...]``` PlotDataItem(list-of-dicts) `[{'x': x, 'y': y, ...},   ...]` PlotDataItem(dict-of-lists) `{'x': [...], 'y': [...],  ...}`

Line style keyword arguments:

 connect Specifies how / whether vertexes should be connected. See below for details. pen Pen to use for drawing the lines between points. Default is solid grey, 1px width. Use None to disable line drawing. May be a `QPen` or any single argument accepted by `mkPen()` shadowPen Pen for secondary line to draw behind the primary line. Disabled by default. May be a `QPen` or any single argument accepted by `mkPen()` fillLevel If specified, the area between the curve and fillLevel is filled. fillOutline (bool) If True, an outline surrounding the fillLevel area is drawn. fillBrush Fill to use in the fillLevel area. May be any single argument accepted by `mkBrush()` stepMode (str or None) If specified and not None, a stepped curve is drawn. For ‘left’ the specified points each describe the left edge of a step. For ‘right’, they describe the right edge. For ‘center’, the x coordinates specify the location of the step boundaries. This mode is commonly used for histograms. Note that it requires an additional x value, such that len(x) = len(y) + 1 .

`connect` supports the following arguments:

• ‘all’ connects all points.

• ‘pairs’ generates lines between every other point.

• ‘finite’ creates a break when a nonfinite points is encountered.

• If an ndarray is passed, it should contain N int32 values of 0 or 1. Values of 1 indicate that the respective point will be connected to the next.

• In the default ‘auto’ mode, PlotDataItem will normally use ‘all’, but if any nonfinite data points are detected, it will automatically switch to ‘finite’.

See `arrayToQPath()` for more details.

Point style keyword arguments: (see `ScatterPlotItem.setData()` for more information)

 symbol Symbol to use for drawing points, or a list of symbols for each. The default is no symbol. symbolPen Outline pen for drawing points, or a list of pens, one per point. May be any single argument accepted by `mkPen()`. symbolBrush Brush for filling points, or a list of brushes, one per point. May be any single argument accepted by `mkBrush()`. symbolSize Diameter of symbols, or list of diameters. pxMode (bool) If True, then symbolSize is specified in pixels. If False, then symbolSize is specified in data coordinates.

Any symbol recognized by `ScatterPlotItem` can be specified, including ‘o’ (circle), ‘s’ (square), ‘t’, ‘t1’, ‘t2’, ‘t3’ (triangles of different orientation), ‘d’ (diamond), ‘+’ (plus sign), ‘x’ (x mark), ‘p’ (pentagon), ‘h’ (hexagon) and ‘star’.

Symbols can also be directly given in the form of a `QtGui.QPainterPath` instance.

Optimization keyword arguments:

 antialias (bool) By default, antialiasing is disabled to improve performance. Note that in some cases (in particular, when `pxMode=True`), points will be rendered antialiased even if this is set to False. downsample (int) Reduce the number of samples displayed by the given factor. downsampleMethod ‘subsample’: Downsample by taking the first of N samples. This method is fastest and least accurate. ‘mean’: Downsample by taking the mean of N samples. ‘peak’: Downsample by drawing a saw wave that follows the min and max of the original data. This method produces the best visual representation of the data but is slower. autoDownsample (bool) If True, resample the data before plotting to avoid plotting multiple line segments per pixel. This can improve performance when viewing very high-density data, but increases the initial overhead and memory usage. clipToView (bool) If True, only data visible within the X range of the containing `ViewBox` is plotted. This can improve performance when plotting very large data sets where only a fraction of the data is visible at any time. dynamicRangeLimit (float or None) Limit off-screen y positions of data points. None disables the limiting. This can increase performance but may cause plots to disappear at high levels of magnification. The default of 1e6 limits data to approximately 1,000,000 times the `ViewBox` height. dynamicRangeHyst (float) Permits changes in vertical zoom up to the given hysteresis factor (the default is 3.0) before the limit calculation is repeated. skipFiniteCheck (bool, default False) Optimization flag that can speed up plotting by not checking and compensating for NaN values. If set to True, and NaN values exist, unpredictable behavior will occur. The data may not be displayed or the plot may take a significant performance hit. In the default ‘auto’ connect mode, PlotDataItem will apply this setting automatically.

Meta-info keyword arguments:

 name (string) Name of item for use in the plot legend

Notes on performance:

Plotting lines with the default single-pixel width is the fastest available option. For such lines, translucent colors (alpha < 1) do not result in a significant slowdown.

Wider lines increase the complexity due to the overlap of individual line segments. Translucent colors require merging the entire plot into a single entity before the alpha value can be applied. For plots with more than a few hundred points, this can result in excessive slowdown.

Since version 0.12.4, this slowdown is automatically avoided by an algorithm that draws line segments separately for fully opaque lines. Setting alpha < 1 reverts to the previous, slower drawing method.

For lines with a width of more than 4 pixels, `pyqtgraph.mkPen()` will automatically create a `QPen` with Qt.PenCapStyle.RoundCap to ensure a smooth connection of line segments. This incurs a small performance penalty.

Methods:

 `update`(data) data is doubled and then every other value is set to 0.5, then `setData()` is used with connect='pairs' to make line segments.

Attributes:

update(data)[source]

data is doubled and then every other value is set to 0.5, then `setData()` is used with connect=’pairs’ to make line segments.

Parameters

data (`numpy.ndarray`) – an x_width x 2 array where column 0 is trial number and column 1 is the value, where value can be “L”, “C”, “R” or a float.

staticMetaObject = <PySide2.QtCore.QMetaObject object at 0x7f41799d71c0>
class Roll_Mean[source]

Shaded area underneath a rolling average.

Typically used as a rolling mean of corrects, so area above and below 0.5 is drawn.

Parameters

winsize (int) – number of trials in the past to take a rolling mean of

Methods:

 `update`(data) Parameters data (`numpy.ndarray`) -- an x_width x 2 array where

Attributes:

update(data)[source]
Parameters

data (`numpy.ndarray`) – an x_width x 2 array where column 0 is trial number and column 1 is the value.

staticMetaObject = <PySide2.QtCore.QMetaObject object at 0x7f41799d7240>

Shaded area for a continuous plot

There are many different ways to create a PlotDataItem.

Data initialization arguments: (x,y data only)

 PlotDataItem(x, y) x, y: array_like coordinate values PlotDataItem(y) y values only – x will be automatically set to `range(len(y))` PlotDataItem(x=x, y=y) x and y given by keyword arguments PlotDataItem(ndarray(N,2)) single numpy array with shape (N, 2), where `x=data[:,0]` and `y=data[:,1]`

Data initialization arguments: (x,y data AND may include spot style)

 PlotDataItem(recarray) numpy record array with ```dtype=[('x', float), ('y', float), ...]``` PlotDataItem(list-of-dicts) `[{'x': x, 'y': y, ...},   ...]` PlotDataItem(dict-of-lists) `{'x': [...], 'y': [...],  ...}`

Line style keyword arguments:

 connect Specifies how / whether vertexes should be connected. See below for details. pen Pen to use for drawing the lines between points. Default is solid grey, 1px width. Use None to disable line drawing. May be a `QPen` or any single argument accepted by `mkPen()` shadowPen Pen for secondary line to draw behind the primary line. Disabled by default. May be a `QPen` or any single argument accepted by `mkPen()` fillLevel If specified, the area between the curve and fillLevel is filled. fillOutline (bool) If True, an outline surrounding the fillLevel area is drawn. fillBrush Fill to use in the fillLevel area. May be any single argument accepted by `mkBrush()` stepMode (str or None) If specified and not None, a stepped curve is drawn. For ‘left’ the specified points each describe the left edge of a step. For ‘right’, they describe the right edge. For ‘center’, the x coordinates specify the location of the step boundaries. This mode is commonly used for histograms. Note that it requires an additional x value, such that len(x) = len(y) + 1 .

`connect` supports the following arguments:

• ‘all’ connects all points.

• ‘pairs’ generates lines between every other point.

• ‘finite’ creates a break when a nonfinite points is encountered.

• If an ndarray is passed, it should contain N int32 values of 0 or 1. Values of 1 indicate that the respective point will be connected to the next.

• In the default ‘auto’ mode, PlotDataItem will normally use ‘all’, but if any nonfinite data points are detected, it will automatically switch to ‘finite’.

See `arrayToQPath()` for more details.

Point style keyword arguments: (see `ScatterPlotItem.setData()` for more information)

 symbol Symbol to use for drawing points, or a list of symbols for each. The default is no symbol. symbolPen Outline pen for drawing points, or a list of pens, one per point. May be any single argument accepted by `mkPen()`. symbolBrush Brush for filling points, or a list of brushes, one per point. May be any single argument accepted by `mkBrush()`. symbolSize Diameter of symbols, or list of diameters. pxMode (bool) If True, then symbolSize is specified in pixels. If False, then symbolSize is specified in data coordinates.

Any symbol recognized by `ScatterPlotItem` can be specified, including ‘o’ (circle), ‘s’ (square), ‘t’, ‘t1’, ‘t2’, ‘t3’ (triangles of different orientation), ‘d’ (diamond), ‘+’ (plus sign), ‘x’ (x mark), ‘p’ (pentagon), ‘h’ (hexagon) and ‘star’.

Symbols can also be directly given in the form of a `QtGui.QPainterPath` instance.

Optimization keyword arguments:

 antialias (bool) By default, antialiasing is disabled to improve performance. Note that in some cases (in particular, when `pxMode=True`), points will be rendered antialiased even if this is set to False. downsample (int) Reduce the number of samples displayed by the given factor. downsampleMethod ‘subsample’: Downsample by taking the first of N samples. This method is fastest and least accurate. ‘mean’: Downsample by taking the mean of N samples. ‘peak’: Downsample by drawing a saw wave that follows the min and max of the original data. This method produces the best visual representation of the data but is slower. autoDownsample (bool) If True, resample the data before plotting to avoid plotting multiple line segments per pixel. This can improve performance when viewing very high-density data, but increases the initial overhead and memory usage. clipToView (bool) If True, only data visible within the X range of the containing `ViewBox` is plotted. This can improve performance when plotting very large data sets where only a fraction of the data is visible at any time. dynamicRangeLimit (float or None) Limit off-screen y positions of data points. None disables the limiting. This can increase performance but may cause plots to disappear at high levels of magnification. The default of 1e6 limits data to approximately 1,000,000 times the `ViewBox` height. dynamicRangeHyst (float) Permits changes in vertical zoom up to the given hysteresis factor (the default is 3.0) before the limit calculation is repeated. skipFiniteCheck (bool, default False) Optimization flag that can speed up plotting by not checking and compensating for NaN values. If set to True, and NaN values exist, unpredictable behavior will occur. The data may not be displayed or the plot may take a significant performance hit. In the default ‘auto’ connect mode, PlotDataItem will apply this setting automatically.

Meta-info keyword arguments:

 name (string) Name of item for use in the plot legend

Notes on performance:

Plotting lines with the default single-pixel width is the fastest available option. For such lines, translucent colors (alpha < 1) do not result in a significant slowdown.

Wider lines increase the complexity due to the overlap of individual line segments. Translucent colors require merging the entire plot into a single entity before the alpha value can be applied. For plots with more than a few hundred points, this can result in excessive slowdown.

Since version 0.12.4, this slowdown is automatically avoided by an algorithm that draws line segments separately for fully opaque lines. Setting alpha < 1 reverts to the previous, slower drawing method.

For lines with a width of more than 4 pixels, `pyqtgraph.mkPen()` will automatically create a `QPen` with Qt.PenCapStyle.RoundCap to ensure a smooth connection of line segments. This incurs a small performance penalty.

Methods:

 `update`(data) Parameters data (`numpy.ndarray`) -- an x_width x 2 array where

Attributes:

update(data)[source]
Parameters

data (`numpy.ndarray`) – an x_width x 2 array where column 0 is time and column 1 is the value.

staticMetaObject = <PySide2.QtCore.QMetaObject object at 0x7f41799d7300>
class HLine[source]

Bases: `PySide2.QtWidgets.QFrame`

A Horizontal line.

Attributes:

staticMetaObject = <PySide2.QtCore.QMetaObject object at 0x7f41799d75c0>
PLOT_LIST = {   'line': <class 'autopilot.gui.plots.geom.Line'>,     'point': <class 'autopilot.gui.plots.geom.Point'>,     'rollmean': <class 'autopilot.gui.plots.geom.Roll_Mean'>,     'segment': <class 'autopilot.gui.plots.geom.Segment'>,     'shaded': <class 'autopilot.gui.plots.geom.Shaded'>}

A dictionary connecting plot keys to objects.

Todo

Just reference the plot objects.