This is documentation for Orange 2.7. For the latest documentation, see Orange 3.

Plot tools (owtools)

OrangeWidgets.plot.owtools.resize_plot_item_list(lst, size, item_type, parent)

Efficiently resizes a list of QGraphicsItems (PlotItems, Curves, etc.). If the list is to be reduced, i.e. if len(lst) > size, then the extra items are first removed from the scene. If items have to be added to the scene, new items will be of type item_type and will have parent as their parent item.

The list is resized in place, this function returns nothing.

Parameters:
  • lst (list of QGraphicsItem) – The list to be resized
  • size (int) – The needed size of the list
  • item_type (type) – The type of items that should be added if the list has to be increased
  • parent (QGraphicsItem) – Any new items will have this as their parent item
OrangeWidgets.plot.owtools.move_item(item, pos, animate=True, duration=None)

Animates item to move to position pos. If animations are turned off globally, the item is instead move immediately, without any animation.

Parameters:
  • item (QGraphicsItem) – The item to move
  • pos (QPointF) – The final position of the item
  • duration (int) – The duration of the animation. If unspecified, Qt’s default value of 250 miliseconds is used.
OrangeWidgets.plot.owtools.move_item_xy(item, x, y, animate=True, duration=None)

Same as move_item(item, QPointF(x, y), duration)

class OrangeWidgets.plot.owtools.TooltipManager(plot)

A dynamic tool tip manager.

Parameters:plot (OWPlot) – The plot used for transforming the coordinates
addToolTip(x, y, text, customX=0, customY=0)

Adds a tool tip. If a tooltip with the same name already exists, it updates it instead of adding a new one.

Parameters:
  • x (float) – The x coordinate of the tip, in data coordinates.
  • y (float) – The y coordinate of the tip, in data coordinates.
  • text (str or int) – The text to show in the tip.
  • customX (float) – The maximum horizontal distance in pixels from the point (x,y) at which to show the tooltip.
  • customY (float) – The maximum vertical distance in pixels from the point (x,y) at which to show the tooltip.

If customX and customY are omitted, a default of 6 pixels is used.

maybeTip(x, y)

Decides whether to pop up a tool tip and which text to show in it.

Parameters:
  • x (float) – the x coordinate of the mouse in data coordinates.
  • y (float) – the y coordinate of the mouse in data coordinates.
Returns:

A tuple consisting of the text, x and y arguments to addToolTip() of the closest point.

Return type:

tuple of (int or str), float, float

removeAll()

Removes all tips

class OrangeWidgets.plot.owtools.PolygonCurve(pen=<PyQt4.QtGui.QPen object at 0x44b1188>, brush=<PyQt4.QtGui.QBrush object at 0x58ed460>, xData=[], yData=[], tooltip=None)

Bases: OrangeWidgets.plot.owcurve.OWCurve

A plot item that shows a filled or empty polygon.

Parameters:
  • pen (QPen) – The pen used to draw the polygon’s outline
  • brush (QBrush) – The brush used to paint the polygon’s inside
  • xData (list of float) – The list of x coordinates
  • yData (list of float) – The list of y coordinates
  • tooltip (str) – The tool tip shown when hovering over this curve
static polygon_from_data(xData, yData)

Creates a polygon from a list of x and y coordinates.

Returns:A polygon with point corresponding to xData and yData.
Return type:QPolygonF
class OrangeWidgets.plot.owtools.RectangleCurve(pen=<PyQt4.QtGui.QPen object at 0x58ed3f8>, brush=<PyQt4.QtGui.QBrush object at 0x58edc80>, xData=None, yData=None, tooltip=None)

Bases: OrangeWidgets.plot.owcurve.OWCurve

A plot item that shows a rectangle.

This class accepts the same options as PolygonCurve. The rectangle is calculated as the smallest rectangle that contains all points in xData and yData.

class OrangeWidgets.plot.owtools.CircleCurve(pen=<PyQt4.QtGui.QPen object at 0x58edce8>, brush=<PyQt4.QtGui.QBrush object at 0x58edd50>, xCenter=0.0, yCenter=0.0, radius=1)

Bases: OrangeWidgets.plot.owcurve.OWCurve

Displays a circle on the plot

Parameters:
  • pen (QPen) – The pen used to draw the outline of the circle
  • brush (QBrush) – The brush used to paint the inside of the circle
  • xCenter (float) – The x coordinate of the circle’s center
  • yCenter (float) – The y coordinate of the circle’s center
  • radius (float) – The circle’s radius
class OrangeWidgets.plot.owtools.UnconnectedLinesCurve(name, pen=<PyQt4.QtGui.QPen object at 0x58edc18>, xData=None, yData=None)

Bases: orangeqt.UnconnectedLinesCurve

A plot item that shows a series of unconnected straight lines.

Parameters:
  • name (str) – The name of this curve. :seealso: OWCurve.name
  • pen (QPen) – The pen used to draw the lines
  • xData (list of float) – The list of x coordinates
  • yData (list of float) – The list of y coordinates

The data should contain an even number of elements. Lines are drawn between the n-th and (n+1)-th point for each even n.

class OrangeWidgets.plot.owtools.Marker(text, x, y, align, bold=0, color=None, brushColor=None, size=None)

Bases: orangeqt.PlotItem

Displays a text marker on the plot.

Parameters:
  • text – The text to display. It can be HTML-formatted
  • x (float) – The x coordinate of the marker’s position
  • y (float) – The y coordinate of the marker’s position
  • align – The text alignment
  • bold (int) – If True, the text will be show bold.
  • color (QColor) – The text color
  • brushColor – The color of the brush user to paint the background
  • size (int) – Font size

Markers have the QGraphicsItem.ItemIgnoresTransformations flag set by default, so text remains the same size when zooming. There is no need to scale the manually.