pyqtgraphRedefine

Module Contents

Classes

Attributes

isOnWindows

Other modified files (directly): ScatterPlotItem.py, to change point selection. Ctrl + clic: select area. Clic: only one single point:

class OnClicSelector:
def __init__(self):
self.p_list = []
def add_point(self, newp):
self.p_list.append(newp)
def draw(self, painter):
if len(self.p_list) > 2:
pen = fn.mkPen(1) pen.setWidthF(2) painter.setPen(pen) painter.drawPolyline(QtGui.QPolygonF(self.p_list))
def reset(self):
self.p_list = []
def getPath(self):
return path.Path([(p.x(), p.y()) for p in self.p_list] + [(self.p_list[-1].x(), self.p_list[-1].y())])
def mouseDragEvent(self, ev):
if ev.modifiers() and QtCore.Qt.ControlModifier:

ev.accept() self.clicSelector.add_point(ev.pos()) if ev.isFinish():

path = self.clicSelector.getPath() points = self.points() contains_points = path.contains_points([(p.pos().x(), p.pos().y()) for p in points]) indices = [i for i, cond in enumerate(contains_points) if cond] points_clicked = [points[i] for i in indices] self.ptsClicked = points_clicked self.sigClicked.emit(self, self.ptsClicked) self.clicSelector.reset()

self.update()

else:
ev.ignore()
class myGraphicsLayoutWidget(parent=None, **_kwargs)[source]

Bases: optimeed.visualize.graphs.pyqtgraph.GraphicsView

Re-implementation of QGraphicsView that removes scrollbars and allows unambiguous control of the viewed coordinate range. Also automatically creates a GraphicsScene and a central QGraphicsWidget that is automatically scaled to the full view geometry.

This widget is the basis for PlotWidget, GraphicsLayoutWidget, and the view widget in ImageView.

By default, the view coordinate system matches the widget’s pixel coordinates and automatically updates when the view is resized. This can be overridden by setting autoPixelRange=False. The exact visible range can be set with setRange().

The view can be panned using the middle mouse button and scaled using the right mouse button if enabled via enableMouse() (but ordinarily, we use ViewBox for this functionality).

useOpenGL(b=True)[source]

Overwrited to fix bad antialiasing while using openGL

class myGraphicsLayout[source]

Bases: optimeed.visualize.graphs.pyqtgraph.GraphicsLayout

Used for laying out GraphicsWidgets in a grid. This is usually created automatically as part of a GraphicsWindow or GraphicsLayoutWidget.

addItem(item, row=None, col=None, rowspan=1, colspan=1)[source]

Add an item to the layout and place it in the next available cell (or in the cell specified). The item must be an instance of a QGraphicsWidget subclass.

set_graph_disposition(item, row=1, col=1, rowspan=1, colspan=1)[source]

Function to modify the position of an item in the list

Parameters:
  • item – WidgetPlotItem to set
  • row – Row
  • col – Column
  • rowspan
  • colspan
Returns:

class myItemSample(item)[source]

Bases: optimeed.visualize.graphs.pyqtgraph.graphicsItems.LegendItem.ItemSample

Class responsible for drawing a single item in a LegendItem (sans label)

set_offset(offset)[source]
set_width_cell(width)[source]
paint(p, *args)[source]

Overwrites to make matlab-like samples

class myLegend(size=None, offset=(30, 30), is_light=False)[source]

Bases: optimeed.visualize.graphs.pyqtgraph.LegendItem

Legend that fixes bugs (flush left + space) from pyqtgraph’s legend

set_space_sample_label(theSpace)[source]

To set the gap between the sample and the label

set_offset_sample(offset)[source]

To tune the offset between the sample and the text

set_width_cell_sample(width)[source]

Set width of sample

updateSize()[source]
addItem(item, name)[source]

Overwrites to flush left

apply_width_sample()[source]
set_font(font_size, font_color, fontname=None)[source]
paint(p, *args)[source]

Overwrited to select background color

set_position(position, offset)[source]

Set the position of the legend, in a corner.

Parameters:
  • position – String (NW, NE, SW, SE), indicates which corner the legend is close
  • offset – Tuple (xoff, yoff), x and y offset from the edge
Returns:

class myLabelItem(text=' ', parent=None, angle=0, **args)[source]

Bases: optimeed.visualize.graphs.pyqtgraph.LabelItem

GraphicsWidget displaying text. Used mainly as axis labels, titles, etc.

Note: To display text inside a scaled view (ViewBox, PlotWidget, etc) use TextItem

setText(text, **args)[source]

Overwrited to add font-family to options

class myAxis(orientation)[source]

Bases: optimeed.visualize.graphs.pyqtgraph.AxisItem

GraphicsItem showing a single plot axis with ticks, values, and label. Can be configured to fit on any side of a plot, Can automatically synchronize its displayed scale with ViewBox items. Ticks can be extended to draw a grid. If maxTickLength is negative, ticks point into the plot.

update_label
_updateLabel()[source]

Internal method to update the label according to the text

get_label_pos()[source]

Overwrited to place label closer to the axis

resizeEvent(ev=None)[source]

Overwrited to place label closer to the axis

set_label_pos(orientation, x_offset=0, y_offset=0)[source]
set_number_ticks(number)[source]