items: Plot primitives

This package provides classes that describes PlotWidget content.

Instances of those classes are returned by PlotWidget methods that give access to its content such as PlotWidget.getCurve(), PlotWidget.getImage().

Item

All plot primitives inherits from Item as a common ground:

class silx.gui.plot.items.Item[source]

Bases: PyQt4.QtCore.QObject

Description of an item of the plot

sigItemChanged

Signal emitted when the item has changed.

It provides a flag describing which property of the item has changed. See ItemChangedType for flags description.

getPlot()[source]

Returns Plot this item belongs to.

Return type:Plot or None
getBounds()[source]

Returns the bounding box of this item in data coordinates

Returns:(xmin, xmax, ymin, ymax) or None
Return type:4-tuple of float or None
isVisible()[source]

True if item is visible, False otherwise

Return type:bool
setVisible(visible)[source]

Set visibility of item.

Parameters:visible (bool) – True to display it, False otherwise
isOverlay()[source]

Return true if item is drawn as an overlay.

Return type:bool
getLegend()[source]

Returns the legend of this item (str)

isSelectable()[source]

Returns true if item is selectable (bool)

getZValue()[source]

Returns the layer on which to draw this item (int)

getInfo(copy=True)[source]

Returns the info associated to this item

Parameters:copy (bool) – True to get a deepcopy, False otherwise.

Curve

class silx.gui.plot.items.Curve[source]

Description of a curve

getAlpha()

Returns the opacity of the item

Return type:float in [0, 1.]
getColor()

Returns the RGBA color of the item

Return type:4-tuple of float in [0, 1] or array of colors
getData(copy=True, displayed=False)

Returns the x, y values of the curve points and xerror, yerror

Parameters:
  • copy (bool) – True (Default) to get a copy, False to use internal representation (do not modify!)
  • displayed (bool) – True to only get curve points that are displayed in the plot. Default: False Note: If plot has log scale, negative points are not displayed.
Returns:

(x, y, xerror, yerror)

Return type:

4-tuple of numpy.ndarray

getLineStyle()

Return the type of the line

Type of line:

- ' '  no line
- '-'  solid line
- '--' dashed line
- '-.' dash-dot line
- ':'  dotted line
Return type:str
getLineWidth()

Return the curve line width in pixels (int)

getSymbol()

Return the point marker type.

Marker type:

- 'o' circle
- '.' point
- ',' pixel
- '+' cross
- 'x' x-cross
- 'd' diamond
- 's' square
Return type:str
getSymbolSize()

Return the point marker size in points.

Return type:float
getXData(copy=True)

Returns the x coordinates of the data points

Parameters:copy – True (Default) to get a copy, False to use internal representation (do not modify!)
Return type:numpy.ndarray
getXErrorData(copy=True)

Returns the x error of the points

Parameters:copy – True (Default) to get a copy, False to use internal representation (do not modify!)
Return type:numpy.ndarray, float or None
getXLabel()

Return the X axis label associated to this curve

Return type:str or None
getYAxis()

Returns the Y axis this curve belongs to.

Either ‘left’ or ‘right’.

Return type:str
getYData(copy=True)

Returns the y coordinates of the data points

Parameters:copy – True (Default) to get a copy, False to use internal representation (do not modify!)
Return type:numpy.ndarray
getYErrorData(copy=True)

Returns the y error of the points

Parameters:copy – True (Default) to get a copy, False to use internal representation (do not modify!)
Return type:numpy.ndarray, float or None
getYLabel()

Return the Y axis label associated to this curve

Return type:str or None
isFill()

Returns whether the item is filled or not.

Return type:bool
isHighlighted()[source]

Returns True if curve is highlighted.

Return type:bool
setAlpha(alpha)

Set the opacity of the item

Note

If the colormap already has some transparency, this alpha adds additional transparency. The alpha channel of the colormap is multiplied by this value.

Parameters:alpha (float) – Opacity of the item, between 0 (full transparency) and 1. (full opacity)
setColor(color, copy=True)

Set item color

Parameters:
  • color (str ("#RRGGBB") or (npoints, 4) unsigned byte array or one of the predefined color names defined in Colors.py) – color(s) to be used
  • copy (bool) – True (Default) to get a copy, False to use internal representation (do not modify!)
setData(x, y, xerror=None, yerror=None, copy=True)

Set the data of the curve.

Parameters:
  • x (numpy.ndarray) – The data corresponding to the x coordinates.
  • y (numpy.ndarray) – The data corresponding to the y coordinates.
  • xerror (A float, or a numpy.ndarray of float32. If it is an array, it can either be a 1D array of same length as the data or a 2D array with 2 rows of same length as the data: row 0 for positive errors, row 1 for negative errors.) – Values with the uncertainties on the x values
  • yerror (A float, or a numpy.ndarray of float32. See xerror.) – Values with the uncertainties on the y values.
  • copy (bool) – True make a copy of the data (default), False to use provided arrays.
setFill(fill)

Set whether to fill the item or not.

Parameters:fill (bool) –
setLineStyle(style)

Set the style of the curve line.

See getLineStyle().

Parameters:style (str) – Line style
setLineWidth(width)

Set the width in pixel of the curve line

See getLineWidth().

Parameters:width (float) – Width in pixels
setSymbol(symbol)

Set the marker type

See getSymbol().

Parameters:symbol (str) – Marker type or marker name
setSymbolSize(size)

Set the point marker size in points.

See getSymbolSize().

Parameters:symbol (str) – Marker type
setYAxis(yaxis)

Set the Y axis this curve belongs to.

Parameters:yaxis (str) – ‘left’ or ‘right’
setHighlighted(highlighted)[source]

Set the highlight state of the curve

Parameters:highlighted (bool) –
getHighlightedColor()[source]

Returns the RGBA highlight color of the item

Return type:4-tuple of int in [0, 255]
setHighlightedColor(color)[source]

Set the color to use when highlighted

Parameters:color (str ("#RRGGBB") or (npoints, 4) unsigned byte array or one of the predefined color names defined in Colors.py) – color(s) to be used for highlight
getCurrentColor()[source]

Returns the current color of the curve.

This color is either the color of the curve or the highlighted color, depending on the highlight state.

Return type:4-tuple of int in [0, 255]

Images

class silx.gui.plot.items.ImageData[source]

Description of a data image with a colormap

getRgbaImageData(copy=True)[source]

Get the displayed RGB(A) image

Returns:numpy.ndarray of uint8 of shape (height, width, 4)
getAlternativeImageData(copy=True)[source]

Get the optional RGBA image that is displayed instead of the data

Parameters:copy – True (Default) to get a copy, False to use internal representation (do not modify!)
Returns:None or numpy.ndarray
Return type:numpy.ndarray or None
getAlpha()

Returns the opacity of the item

Return type:float in [0, 1.]
getColormap()

Return the used colormap

getData(copy=True)

Returns the image data

Parameters:copy (bool) – True (Default) to get a copy, False to use internal representation (do not modify!)
Return type:numpy.ndarray
getOrigin()

Returns the offset from origin at which to display the image.

Return type:2-tuple of float
getScale()

Returns the scale of the image in data coordinates.

Return type:2-tuple of float
isDraggable()

Returns true if image is draggable

Return type:bool
setAlpha(alpha)

Set the opacity of the item

Note

If the colormap already has some transparency, this alpha adds additional transparency. The alpha channel of the colormap is multiplied by this value.

Parameters:alpha (float) – Opacity of the item, between 0 (full transparency) and 1. (full opacity)
setColormap(colormap)

Set the colormap of this image

Parameters:colormap (silx.gui.plot.Colormap.Colormap) – colormap description
setOrigin(origin)

Set the offset from origin at which to display the image.

Parameters:origin (float or 2-tuple of float) – (ox, oy) Offset from origin
setScale(scale)

Set the scale of the image

Parameters:scale (float or 2-tuple of float) – (sx, sy) Scale of the image
class silx.gui.plot.items.ImageRgba[source]

Description of an RGB(A) image

getRgbaImageData(copy=True)[source]

Get the displayed RGB(A) image

Returns:numpy.ndarray of uint8 of shape (height, width, 4)
getAlpha()

Returns the opacity of the item

Return type:float in [0, 1.]
getData(copy=True)

Returns the image data

Parameters:copy (bool) – True (Default) to get a copy, False to use internal representation (do not modify!)
Return type:numpy.ndarray
getOrigin()

Returns the offset from origin at which to display the image.

Return type:2-tuple of float
getScale()

Returns the scale of the image in data coordinates.

Return type:2-tuple of float
isDraggable()

Returns true if image is draggable

Return type:bool
setAlpha(alpha)

Set the opacity of the item

Note

If the colormap already has some transparency, this alpha adds additional transparency. The alpha channel of the colormap is multiplied by this value.

Parameters:alpha (float) – Opacity of the item, between 0 (full transparency) and 1. (full opacity)
setOrigin(origin)

Set the offset from origin at which to display the image.

Parameters:origin (float or 2-tuple of float) – (ox, oy) Offset from origin
setScale(scale)

Set the scale of the image

Parameters:scale (float or 2-tuple of float) – (sx, sy) Scale of the image

Scatter

class silx.gui.plot.items.Scatter[source]

Description of a scatter

getValueData(copy=True)[source]

Returns the value assigned to the scatter data points.

Parameters:copy – True (Default) to get a copy, False to use internal representation (do not modify!)
Return type:numpy.ndarray
getData(copy=True, displayed=False)[source]

Returns the x, y coordinates and the value of the data points

Parameters:
  • copy – True (Default) to get a copy, False to use internal representation (do not modify!)
  • displayed (bool) – True to only get curve points that are displayed in the plot. Default: False. Note: If plot has log scale, negative points are not displayed.
Returns:

(x, y, value, xerror, yerror)

Return type:

5-tuple of numpy.ndarray

getAlpha()

Returns the opacity of the item

Return type:float in [0, 1.]
getColormap()

Return the used colormap

getSymbol()

Return the point marker type.

Marker type:

- 'o' circle
- '.' point
- ',' pixel
- '+' cross
- 'x' x-cross
- 'd' diamond
- 's' square
Return type:str
getSymbolSize()

Return the point marker size in points.

Return type:float
getXData(copy=True)

Returns the x coordinates of the data points

Parameters:copy – True (Default) to get a copy, False to use internal representation (do not modify!)
Return type:numpy.ndarray
getXErrorData(copy=True)

Returns the x error of the points

Parameters:copy – True (Default) to get a copy, False to use internal representation (do not modify!)
Return type:numpy.ndarray, float or None
getYData(copy=True)

Returns the y coordinates of the data points

Parameters:copy – True (Default) to get a copy, False to use internal representation (do not modify!)
Return type:numpy.ndarray
getYErrorData(copy=True)

Returns the y error of the points

Parameters:copy – True (Default) to get a copy, False to use internal representation (do not modify!)
Return type:numpy.ndarray, float or None
setAlpha(alpha)

Set the opacity of the item

Note

If the colormap already has some transparency, this alpha adds additional transparency. The alpha channel of the colormap is multiplied by this value.

Parameters:alpha (float) – Opacity of the item, between 0 (full transparency) and 1. (full opacity)
setColormap(colormap)

Set the colormap of this image

Parameters:colormap (silx.gui.plot.Colormap.Colormap) – colormap description
setData(x, y, value, xerror=None, yerror=None, copy=True)[source]

Set the data of the scatter.

Parameters:
  • x (numpy.ndarray) – The data corresponding to the x coordinates.
  • y (numpy.ndarray) – The data corresponding to the y coordinates.
  • value (numpy.ndarray) – The data corresponding to the value of the data points.
  • xerror (A float, or a numpy.ndarray of float32. If it is an array, it can either be a 1D array of same length as the data or a 2D array with 2 rows of same length as the data: row 0 for positive errors, row 1 for negative errors.) – Values with the uncertainties on the x values
  • yerror (A float, or a numpy.ndarray of float32. See xerror.) – Values with the uncertainties on the y values
  • copy (bool) – True make a copy of the data (default), False to use provided arrays.
setSymbol(symbol)

Set the marker type

See getSymbol().

Parameters:symbol (str) – Marker type or marker name
setSymbolSize(size)

Set the point marker size in points.

See getSymbolSize().

Parameters:symbol (str) – Marker type

Histogram

class silx.gui.plot.items.Histogram[source]

Description of an histogram

getAlpha()

Returns the opacity of the item

Return type:float in [0, 1.]
getColor()

Returns the RGBA color of the item

Return type:4-tuple of float in [0, 1] or array of colors
getLineStyle()

Return the type of the line

Type of line:

- ' '  no line
- '-'  solid line
- '--' dashed line
- '-.' dash-dot line
- ':'  dotted line
Return type:str
getLineWidth()

Return the curve line width in pixels (int)

getValueData(copy=True)[source]

The values of the histogram

Parameters:copy – True (Default) to get a copy, False to use internal representation (do not modify!)
Returns:The bin edges of the histogram
Return type:numpy.ndarray
getYAxis()

Returns the Y axis this curve belongs to.

Either ‘left’ or ‘right’.

Return type:str
isFill()

Returns whether the item is filled or not.

Return type:bool
setAlpha(alpha)

Set the opacity of the item

Note

If the colormap already has some transparency, this alpha adds additional transparency. The alpha channel of the colormap is multiplied by this value.

Parameters:alpha (float) – Opacity of the item, between 0 (full transparency) and 1. (full opacity)
setColor(color, copy=True)

Set item color

Parameters:
  • color (str ("#RRGGBB") or (npoints, 4) unsigned byte array or one of the predefined color names defined in Colors.py) – color(s) to be used
  • copy (bool) – True (Default) to get a copy, False to use internal representation (do not modify!)
setFill(fill)

Set whether to fill the item or not.

Parameters:fill (bool) –
setLineStyle(style)

Set the style of the curve line.

See getLineStyle().

Parameters:style (str) – Line style
setLineWidth(width)

Set the width in pixel of the curve line

See getLineWidth().

Parameters:width (float) – Width in pixels
setYAxis(yaxis)

Set the Y axis this curve belongs to.

Parameters:yaxis (str) – ‘left’ or ‘right’
getBinEdgesData(copy=True)[source]

The bin edges of the histogram (number of histogram values + 1)

Parameters:copy – True (Default) to get a copy, False to use internal representation (do not modify!)
Returns:The bin edges of the histogram
Return type:numpy.ndarray
getData(copy=True)[source]

Return the histogram values and the bin edges

Parameters:copy – True (Default) to get a copy, False to use internal representation (do not modify!)
Returns:(N histogram value, N+1 bin edges)
Return type:2-tuple of numpy.nadarray
setData(histogram, edges, align='center', copy=True)[source]

Set the histogram values and bin edges.

Parameters:
  • histogram (numpy.ndarray) – The values of the histogram.
  • edges (numpy.ndarray) – The bin edges of the histogram. If histogram and edges have the same length, the bin edges are computed according to the align parameter.
  • align (str) – In case histogram values and edges have the same length N, the N+1 bin edges are computed according to the alignment in: ‘center’ (default), ‘left’, ‘right’.
  • copy (bool) – True make a copy of the data (default), False to use provided arrays.

Markers

class silx.gui.plot.items.Marker[source]

Description of a marker

getConstraint()

Returns the dragging constraint of this item

getPosition()

Returns the (x, y) position of the marker in data coordinates

Return type:2-tuple of float or None
getSymbol()

Return the point marker type.

Marker type:

- 'o' circle
- '.' point
- ',' pixel
- '+' cross
- 'x' x-cross
- 'd' diamond
- 's' square
Return type:str
getSymbolSize()

Return the point marker size in points.

Return type:float
getText()

Returns marker text.

Return type:str
getXPosition()

Returns the X position of the marker line in data coordinates

Return type:float or None
getYPosition()

Returns the Y position of the marker line in data coordinates

Return type:float or None
setPosition(x, y)

Set marker position in data coordinates

Constraint are applied if any.

Parameters:
  • x (float) – X coordinates in data frame
  • y (float) – Y coordinates in data frame
setSymbol(symbol)

Set the marker type

See getSymbol().

Parameters:symbol (str) – Marker type or marker name
setSymbolSize(size)

Set the point marker size in points.

See getSymbolSize().

Parameters:symbol (str) – Marker type
setText(text)

Set the text of the marker.

Parameters:text (str) – The text to use
class silx.gui.plot.items.XMarker[source]

Description of a marker

setPosition(x, y)[source]

Set marker line position in data coordinates

Constraint are applied if any.

Parameters:
  • x (float) – X coordinates in data frame
  • y (float) – Y coordinates in data frame
getConstraint()

Returns the dragging constraint of this item

getPosition()

Returns the (x, y) position of the marker in data coordinates

Return type:2-tuple of float or None
getText()

Returns marker text.

Return type:str
getXPosition()

Returns the X position of the marker line in data coordinates

Return type:float or None
getYPosition()

Returns the Y position of the marker line in data coordinates

Return type:float or None
setText(text)

Set the text of the marker.

Parameters:text (str) – The text to use
class silx.gui.plot.items.YMarker[source]

Description of a marker

getConstraint()

Returns the dragging constraint of this item

getPosition()

Returns the (x, y) position of the marker in data coordinates

Return type:2-tuple of float or None
getText()

Returns marker text.

Return type:str
getXPosition()

Returns the X position of the marker line in data coordinates

Return type:float or None
getYPosition()

Returns the Y position of the marker line in data coordinates

Return type:float or None
setText(text)

Set the text of the marker.

Parameters:text (str) – The text to use
setPosition(x, y)[source]

Set marker line position in data coordinates

Constraint are applied if any.

Parameters:
  • x (float) – X coordinates in data frame
  • y (float) – Y coordinates in data frame

Shapes

class silx.gui.plot.items.Shape(type_)[source]

Description of a shape item

Parameters:type (str) – The type of shape in: ‘hline’, ‘polygon’, ‘rectangle’, ‘vline’, ‘polylines’
setOverlay(overlay)[source]

Set the overlay state of the shape

Parameters:overlay (bool) – True to make it an overlay
getType()[source]

Returns the type of shape to draw.

One of: ‘hline’, ‘polygon’, ‘rectangle’, ‘vline’, ‘polylines’

Return type:str
getPoints(copy=True)[source]

Get the control points of the shape.

Parameters:copy (bool) – True (Default) to get a copy, False to use internal representation (do not modify!)
Returns:Array of point coordinates
Return type:numpy.ndarray with 2 dimensions
setPoints(points, copy=True)[source]

Set the point coordinates

Parameters:
  • points (numpy.ndarray) – Array of point coordinates
  • copy (bool) – True (Default) to get a copy, False to use internal representation (do not modify!)
Returns:

getColor()

Returns the RGBA color of the item

Return type:4-tuple of float in [0, 1] or array of colors
isFill()

Returns whether the item is filled or not.

Return type:bool
setColor(color, copy=True)

Set item color

Parameters:
  • color (str ("#RRGGBB") or (npoints, 4) unsigned byte array or one of the predefined color names defined in Colors.py) – color(s) to be used
  • copy (bool) – True (Default) to get a copy, False to use internal representation (do not modify!)
setFill(fill)

Set whether to fill the item or not.

Parameters:fill (bool) –

Item changed signal

Plot items emit a Item.sigItemChanged signal when their values are updated. This signal provides a flag in the following enumeration describing the modified value:

class silx.gui.plot.items.ItemChangedType[source]

Type of modification provided by Item.sigItemChanged signal.

VISIBLE = <ItemChangedType.VISIBLE: 'visibleChanged'>

Item’s visibility changed flag.

ZVALUE = <ItemChangedType.ZVALUE: 'zValueChanged'>

Item’s Z value changed flag.

COLORMAP = <ItemChangedType.COLORMAP: 'colormapChanged'>

Item’s colormap changed flag.

This is emitted both when setting a new colormap and when the current colormap object is updated.

SYMBOL = <ItemChangedType.SYMBOL: 'symbolChanged'>

Item’s symbol changed flag.

SYMBOL_SIZE = <ItemChangedType.SYMBOL_SIZE: 'symbolSizeChanged'>

Item’s symbol size changed flag.

LINE_WIDTH = <ItemChangedType.LINE_WIDTH: 'lineWidthChanged'>

Item’s line width changed flag.

LINE_STYLE = <ItemChangedType.LINE_STYLE: 'lineStyleChanged'>

Item’s line style changed flag.

COLOR = <ItemChangedType.COLOR: 'colorChanged'>

Item’s color changed flag.

YAXIS = <ItemChangedType.YAXIS: 'yAxisChanged'>

Item’s Y axis binding changed flag.

FILL = <ItemChangedType.FILL: 'fillChanged'>

Item’s fill changed flag.

ALPHA = <ItemChangedType.ALPHA: 'alphaChanged'>

Item’s transparency alpha changed flag.

DATA = <ItemChangedType.DATA: 'dataChanged'>

Item’s data changed flag

HIGHLIGHTED = <ItemChangedType.HIGHLIGHTED: 'highlightedChanged'>

Item’s highlight state changed flag.

HIGHLIGHTED_COLOR = <ItemChangedType.HIGHLIGHTED_COLOR: 'highlightedColorChanged'>

Item’s highlighted color changed flag.

SCALE = <ItemChangedType.SCALE: 'scaleChanged'>

Item’s scale changed flag.

TEXT = <ItemChangedType.TEXT: 'textChanged'>

Item’s text changed flag.

POSITION = <ItemChangedType.POSITION: 'positionChanged'>

Item’s position changed flag.

This is emitted when a marker position changed and when an image origin changed.

OVERLAY = <ItemChangedType.OVERLAY: 'overlayChanged'>

Item’s overlay state changed flag.

VISUALIZATION_MODE = <ItemChangedType.VISUALIZATION_MODE: 'visualizationModeChanged'>

Item’s visualization mode changed flag.

Axis

class silx.gui.plot.items.Axis(plot)[source]

This class describes and controls a plot axis.

Note: This is an abstract class.

LINEAR = 'linear'

Constant defining a linear scale

LOGARITHMIC = 'log'

Constant defining a logarithmic scale

sigInvertedChanged

Signal emitted when axis orientation has changed

sigScaleChanged

Signal emitted when axis scale has changed

sigAutoScaleChanged

Signal emitted when axis autoscale has changed

sigLimitsChanged

Signal emitted when axis limits have changed

getLimits()[source]

Get the limits of this axis.

Returns:Minimum and maximum values of this axis as tuple
setLimits(vmin, vmax)[source]

Set this axis limits.

Parameters:
  • vmin (float) – minimum axis value
  • vmax (float) – maximum axis value
isInverted()[source]

Return True if the axis is inverted (top to bottom for the y-axis), False otherwise. It is always False for the X axis.

Return type:bool
setInverted(isInverted)[source]

Set the axis orientation.

This is only available for the Y axis.

Parameters:flag (bool) – True for Y axis going from top to bottom, False for Y axis going from bottom to top
getLabel()[source]

Return the current displayed label of this axis.

Parameters:axis (str) – The Y axis for which to get the label (left or right)
Return type:str
setLabel(label)[source]

Set the label displayed on the plot for this axis.

The provided label can be temporarily replaced by the label of the active curve if any.

Parameters:label (str) – The axis label
getScale()[source]

Return the name of the scale used by this axis.

Return type:str
setScale(scale)[source]

Set the scale to be used by this axis.

Parameters:scale (str) – Name of the scale (“log”, or “linear”)
isAutoScale()[source]

Return True if axis is automatically adjusting its limits.

Return type:bool
setAutoScale(flag=True)[source]

Set the axis limits adjusting behavior of resetZoom().

Parameters:flag (bool) – True to resize limits automatically, False to disable it.
setLimitsConstraints(minPos=None, maxPos=None)[source]

Set a constraint on the position of the axes.

Parameters:
  • minPos (float) – Minimum allowed axis value.
  • maxPos (float) – Maximum allowed axis value.
Returns:

True if the constaints was updated

Return type:

bool

setRangeConstraints(minRange=None, maxRange=None)[source]

Set a constraint on the position of the axes.

Parameters:
  • minRange (float) – Minimum allowed left-to-right span across the view
  • maxRange (float) – Maximum allowed left-to-right span across the view
Returns:

True if the constaints was updated

Return type:

bool