def __init__(self): QMainWindow.__init__(self) self.setWindowTitle("Cross hair floating Lable ") self.axis = pg.DateAxisItem(orientation='bottom') self.pDraw = pg.GraphicsLayoutWidget(show=True) self.pDraw.setBackground((0, 0, 0)) self.setCentralWidget(self.pDraw) #Create plot and add Items to it self.p1 = self.pDraw.addPlot( row=0, col=0, axisItems={'bottom': pg.DateAxisItem(orientation='bottom')}) self.curve1 = self.p1.plot() self.vLine = pg.InfiniteLine(angle=90, movable=False) self.hLine = pg.InfiniteLine(angle=0, movable=False) self.label = pg.TextItem("") self.p1.addItem(self.label, ignoreBounds=False) self.p1.addItem(self.vLine, ignoreBounds=True) self.p1.addItem(self.hLine, ignoreBounds=True) #initialize Timer, connect its timout Event Signal to UpdatePlot Slot self.timer_update_events = QTimer() self.timer_update_events.timeout.connect(self.updatePlot) self.timer_update_events.start(200) #initialize Crosshair lable and connect mouse movment to mouseMoved self.vb = self.p1.vb self.proxy = pg.SignalProxy(self.p1.scene().sigMouseMoved, rateLimit=60, slot=self.mouseMoved) self.updatePlot() self.label.setPos(x[0], 0)
def __init__(self, parent=None): super(DiodeThermometerWidget, self).__init__(parent) self.setupUi(self) self.outputFile = None axis = pg.DateAxisItem(orientation='bottom') self.plot = pg.PlotWidget(axisItems={'bottom': axis}) self.verticalLayout.addWidget(self.plot) self.plot.addLegend() self.curve = pg.PlotCurveItem( name='DC', symbol='o', pen='g', ) self.plot.setLabel('bottom', 'time') self.plot.addItem(self.curve) self.clearData() self.msmThread = None self.settingsWidgets = [ self.dmmVisaCombo, self.currentCombo, self.thermometerCombo, self.yAxisCombo ] self.restoreSettings() self.startPb.clicked.connect(self.startPbClicked) self.stopPb.clicked.connect(self.stopPbClicked) self.clearPb.clicked.connect(self.clearData) self.yAxisCombo.currentIndexChanged.connect(self.updatePlot)
def __init__(self, parent=None): super(PlotWidget2, self).__init__(parent) self.axisItem = {'bottom': pg.DateAxisItem()} self.plotItem.getViewBox().setMouseMode( self.plotItem.getViewBox().RectMode) self.proxy1 = QtGui.QGraphicsProxyWidget() self.proxy2 = QtGui.QGraphicsProxyWidget() self.button1 = QtGui.QPushButton('Добавить полку на спуске') self.button1.setVisible(False) self.button2 = QtGui.QPushButton('Добавить полку на подъеме') self.button2.setVisible(False) self.proxy1.setWidget(self.button1) self.proxy2.setWidget(self.button2) self.proxy1.setGeometry(QtCore.QRectF(52, 0, 143, 23)) self.proxy2.setGeometry( QtCore.QRectF(self.plotItem.geometry().getCoords()[2] - 197, 0, 153, 23)) self.plotItem.scene().addItem(self.proxy1) self.plotItem.scene().addItem(self.proxy2) self.plot2 = pg.ViewBox() self.button1.clicked.connect(lambda: self.btnSpuskPressedSignal.emit()) self.button2.clicked.connect(lambda: self.btnPodemPressedSignal.emit()) self.sigRangeChanged.connect(self.updatePlot2YRange) self.data = None self.maxYLeft, self.minYLeft = None, None self.minYRight, self.maxYRight = None, None self.plotItem.setAxisItems(self.axisItem) self.plotItem.getAxis('left').setLabel( 'Pressure, at., Temperature, °C') self.plotItem.addLegend() self.plotItem.showAxis('right') self.plotItem.getAxis('right').setLabel('Depth, m.') self.plotItem.showGrid(True, True, alpha=0.3) self.infLines = []
def __init__(self, parent=None): super(PMPyQtGraphWidget, self).__init__(parent) self.resize(600, 600) self.lines = [] # 1 pg.setConfigOptions(leftButtonPan=False) pg.setConfigOption('background', 'w') pg.setConfigOption('foreground', 'k') # 2 # x = np.random.normal(size=1000) # y = np.random.normal(size=1000) # r_symbol = random.choice(['o', 's', 't', 't1', 't2', 't3', 'd', '+', 'x', 'p', 'h', 'star']) # r_color = random.choice(['b', 'g', 'r', 'c', 'm', 'y', 'k', 'd', 'l', 's']) # 3 self.pw = pg.PlotWidget(self, axisItems={'bottom': pg.DateAxisItem()}) # self.plot_data = self.pw.plot(x, y, pen=None, symbol=r_symbol, symbolBrush=r_color) # 4 # self.plot_btn = QPushButton('Replot', self) # # self.plot_btn.clicked.connect(self.plot_slot) self.v_layout = QVBoxLayout() self.v_layout.addWidget(self.pw) # self.v_layout.addWidget(self.plot_btn) self.setLayout(self.v_layout)
def __init__(self, parent=None, face_color=None, text_color=None): super().__init__(parent, text_color=text_color) self.face_color = face_color self.text_color = text_color self.plot_widget = pg.PlotWidget( self, axisItems={'bottom': pg.DateAxisItem()}, background=self.face_color) self.legend = self.plot_widget.addLegend( brush=QBrush(QColor(255, 255, 255)), offset=(-10, 10), labelTextColor=self.text_color, labelTextSize=8) self.v_layout.addWidget(self.plot_widget) # self.setMinimumSize(300, 200) # self.setMaximumSize(450, 300) self.xlabel: str = '' self.ylabel: str = '' self.threshold_range: TYPE_RANGE = None self.x_range: Tuple[float, float] = None self.y_range: Tuple[float, float] = None self.title: str = '' self.ticks = 5 self.show_data_num = 10 self.max_data = 200 self.timestamp_list = [] self.value_list = [] self.repaint_all = False
def __init__( self, item: Union[Iterable[PlotItem[X]], PlotItem[X]], title: str, datetime_x_axis: bool = False, show_x_crosshair: bool = False, crosshair_move_callback: Callable[[X], None] = lambda x: None, link_group: LinkGroup = None, ): self._datetime_x_axis = datetime_x_axis # These are global config options, but there's no neat place to put them so we just # repeatedly initialize them to the same value in here pg.setConfigOption("background", globals.BG_COLOR) pg.setConfigOption("foreground", globals.TEXT_COLOR) axes = {} if datetime_x_axis: axes["bottom"] = pg.DateAxisItem(orientation="bottom") super().__init__(axisItems=axes) plot: pg.PlotItem = self.getPlotItem() plot.setTitle(title) plot.showGrid(x=True, y=True, alpha=0.15) self._setup_items_and_legend( [item] if isinstance(item, PlotItem) else list(item)) self._setup_crosshair(show_x_crosshair, crosshair_move_callback, link_group)
def __init__(self, data_buffer_length): super(GraphViewer, self).__init__() self.buffer_samples = data_buffer_length # Define the number of graphs in the grid: graphs_vertical = 2 graphs_horizontal = 2 # Appearance settings: self.pen_style = pg.mkPen(color="y", width=2, style=QtCore.Qt.SolidLine) self.title_color = "w" self.title_size = "13pt" self.axis_color = "w" self.axis_label_style = {'color': '#FFF', 'font-size': '11pt'} self.x_grid = False self.y_grid = False # Labels and measurement units for display self.C_label = "\u00B0C" self.F_label = "\u00B0F" self.SDS_unit = "\u00B5g/m\u00B3" self.PPD_unit = "ppL" self.names_units = OrderedDict([('Temperature', self.C_label), ('Pressure', 'Pa'),('Humidity', '%'),('Gas sensor resistance', "\u03A9"), ('Air Quality Index', ''),('Estimated CO\u2082', 'ppm'),('Equivalent breath VOC', 'ppm'), ('Air quality accuracy', ''),('Illuminance', 'lux'),('White light level', ''), ('Sound pressure level', 'dBA'),('Band 1 SPL', 'dB'),('Band 2 SPL', 'dB'), ('Band 3 SPL', 'dB'),('Band 4 SPL', 'dB'),('Band 5 SPL', 'dB'), ('Band 6 SPL', 'dB'),('Peak sound amplitude', 'mPa'),('Microphone initialized', ''), ('Particle sensor duty cycle', '%'),('Particle concentration', self.PPD_unit), ('Particle data valid', '')]) self.decimal_places = [1,0,1,0,1,1,2,0,2,0,1,1,1,1,1,1,1,2,0,2,2,0] self.sound_band_number = 6 # Construct the user interface self.setWindowTitle('Waiting for data...') self.widget = QtGui.QWidget() self.setCentralWidget(self.widget) self.widget.setLayout(QtGui.QGridLayout()) self.graph_var_numbers = [] self.selected_var_numbers = [] self.plot_items = [] self.plot_handles = [] self.combos = [] self.is_bar_chart = [] for nv in range(0,graphs_vertical): for nh in range(0,graphs_horizontal): GLW = pg.GraphicsLayoutWidget() combo = pg.ComboBox() self.combos.append(combo) self.widget.layout().addWidget(combo, (2*nv), nh) self.widget.layout().addWidget(GLW, (2*nv)+1, nh) new_plot = GLW.addPlot() self.plot_items.append(new_plot) self.plot_handles.append(new_plot.plot(pen=self.pen_style, symbol=None, axisItems={'bottom': pg.DateAxisItem()})) self.formatPlotItem(new_plot) self.is_bar_chart.append(False) self.time_data = deque(maxlen=self.buffer_samples)
def __init__(self, parent): super().__init__() self.db = parent.db # Candlestick init self.candlestick = CandlestickItem(self.db) self.volumeProfile = VolumeProfileItem(self.db) self.volumeProfile.onUpdate.connect(self.candlestick.update) self.candlestickWidget = pg.PlotWidget( self, axisItems={"bottom": pg.DateAxisItem()}) self.candlestickWidget.addItem(self.candlestick) self.candlestickWidget.addItem(self.volumeProfile) self.candlestickWidget.setMouseEnabled(x=True, y=False) self.candlestickWidget.enableAutoRange(x=False, y=True) self.candlestickWidget.setAutoVisible(x=False, y=True) self.candlestickWidget.showAxis("right") self.candlestickWidget.hideAxis("left") self.candlestickWidget.showGrid(True, True, 0.2) self.candlestickWidget.scene().sigMouseMoved.connect( self.candlestick.onMouseMoved) # Add dock self.d = Dock("OHLC", widget=self.candlestickWidget) self.addDock(self.d)
def __init__(self, parent=None): super(PiezoControlWidget, self).__init__(parent) self.setupUi(self) self.voltageIndicator.setUnit('V') self.currentIndicator.setUnit('A') self.powerIndicator.setUnit('W') self.outputFile = None axis = pg.DateAxisItem(orientation='bottom') self.plot = pg.PlotWidget(axisItems={'bottom': axis}) self.verticalLayout.addWidget(self.plot) self.plot.addLegend() self.curve = pg.PlotCurveItem(name='DC', symbol='o', pen='g', ) self.plot.setLabel('bottom', 'time') self.plot.addItem(self.curve) self.clearData() self.msmThread = None self.restoreSettings() self.startPb.clicked.connect(self.startPbClicked) self.stopPb.clicked.connect(self.stopPbClicked) self.clearPb.clicked.connect(self.clearData) self.yAxisCombo.currentIndexChanged.connect(self.updatePlot) self.serverThread = RequestReplyThreadWithBindings(port=RequestReply.PiezoControl, parent=self) boundWidgets = {'rampRate':self.rampRateSb, 'rampTarget':self.rampTargetSb, 'go':self.goPb} for name in boundWidgets: self.serverThread.bindToWidget(name, boundWidgets[name]) self.serverThread.start()
def set_time_x_axis(self, widget): """Set the time on the X axis :param widget: The widget on which to add time :type widget: Plot """ widget.setAxisItems({"bottom": pg.DateAxisItem(orientation="bottom")})
def plot(self, x_axis_name, x_axis_data, y_axis_name, y_axis_data): self.plots[y_axis_name] = self.plot_area.plot(x_axis_data, y_axis_data, pen=pg.mkPen(qt_colors[self._current_color], width=1.5)) self._current_color += 1 self.x_axis_name = x_axis_name if 'time' in x_axis_name.lower(): axis = pg.DateAxisItem() self.plot_area.setAxisItems({'bottom': axis})
def formatPlotItem(self, item): item.setMenuEnabled(False) item.showGrid(x=self.x_grid, y=self.y_grid) item.getAxis("left").setPen(pg.mkPen(self.axis_color)) item.getAxis("bottom").setPen(pg.mkPen(self.axis_color)) item.getAxis("left").setStyle(tickLength=7) item.getAxis("bottom").setStyle(tickLength=7) item.setAxisItems({'bottom':pg.DateAxisItem()})
def toggleVolume(self, checked): if checked: volumeWidget = pg.PlotWidget( axisItems={"bottom": pg.DateAxisItem()}) plotItem = volumeItem(self) volumeWidget.addItem(plotItem) self.addPlot("volume", volumeWidget) else: self.removePlot("volume")
def __init__(self, topics=None, terms=None, addr=None, parent=None, **kwargs): super().__init__(topics, terms, addr, parent=parent, **kwargs) self.graphics_layout.useOpenGL(False) ax = pg.DateAxisItem(orientation='bottom') self.plot_view.setAxisItems({'bottom': ax})
def __init__(self, parent=None): super(MagnetControlWidget, self).__init__(parent) self.setupUi(self) self.magnetThread = None axis = pg.DateAxisItem(orientation='bottom') self.plot = pg.PlotWidget(axisItems={'bottom': axis}) self.verticalLayout_3.addWidget(self.plot) self.curve = pg.PlotCurveItem(name='Actual', symbol='o', pen='g') self.plot.addItem(self.curve) self.clearData() self.yaxisCombo.currentIndexChanged.connect(self.switchPlotAxis) self.switchPlotAxis()
def plot_bars(self, x_axis_name, x_axis_data, y_axis_name, y_axis_data): self.type = 'bars' color = qt_colors[self._current_color] self.x_axis_name = x_axis_name bg1 = pg.BarGraphItem(x=x_axis_data, height=y_axis_data, width=0.5, brush=color, pen=color) # bg1 = pg.BarGraphItem(x=x_axis_data, height=x_axis_data, width=0.5) self.plot_area.addItem(bg1) self.plots[y_axis_name] = bg1 self._current_color += 1 if 'time' in x_axis_name.lower(): axis = pg.DateAxisItem() self.plot_area.setAxisItems({'bottom': axis})
def plot_stacked_bars(self, x_axis_name, x_axis_data, y_axis_prev_data, y_axis_name, y_axis_data, y_data_to_show): self.type = 'stacked_bars' color = qt_colors[self._current_color] self.x_axis_name = x_axis_name bg1 = pg.BarGraphItem(x=x_axis_data, y0=y_axis_prev_data, y1=y_axis_data, width=0.5, brush=color, pen=color) self.plot_area.addItem(bg1) self.plots[y_axis_name] = bg1 self._current_color += 1 if 'time' in x_axis_name.lower(): axis = pg.DateAxisItem() self.plot_area.setAxisItems({'bottom': axis})
def __init__(self, parent=None, **kargs): axis = pg.DateAxisItem(orientation='bottom') super(TimePlotWidget, self).__init__(parent, axisItems={'bottom': axis}, **kargs) self.setMouseEnabled(y=False) self._range = DisplayRange.DEFAULT # Current time indicator (vertical line) self.v_line = pg.InfiniteLine(angle=90, movable=False, pen='g') self.addItem(self.v_line) self.sigRangeChanged.connect(self.on_axis_range_changed)
def __init__(self): super().__init__() self.setupUi(self) now = time.time() # Plot random values with timestamps in the last 6 months timestamps = np.linspace(now - 6 * 30 * 24 * 3600, now, 100) self.curve = self.plotWidget.plot(x=timestamps, y=np.random.rand(100), symbol='o', symbolSize=5, pen=BLUE) # 'o' circle 't' triangle 'd' diamond '+' plus 's' square self.plotWidget.setAxisItems({'bottom': pg.DateAxisItem()}) self.plotWidget.showGrid(x=True, y=True)
def plot(self, *args, **kwargs): self.plot_widget.parametric = kwargs.pop('parametric', False) if kwargs.get('timeaxis', '') == 'True': # strange scaling when zoom axis = pg.DateAxisItem() self.plot_widget.setAxisItems({'bottom': axis}) self.plot_widget.setLabel("bottom", text=kwargs.get('xname', '')) else: self.plot_widget.setLabel("bottom", text=kwargs.get('xname', ''), units=kwargs.get('xscale', '')) self.plot_widget.setLabel("left", text=kwargs.get('yname', ''), units=kwargs.get('yscale', '')) name = kwargs.get('name', '') if name in self.curves: if kwargs.get('scatter', '') == 'True': kwargs['pen'] = None kwargs['symbol'] = self.used_symbols[name] kwargs['symbolPen'] = self.used_pens[name] kwargs['symbolBrush'] = self.used_brush[name] kwargs['symbolSize'] = 7 self.curves[name].setData(*args, **kwargs) elif kwargs.get('scatter', '') == 'False': kwargs['pen'] = self.used_colors[name] self.curves[name].setData(*args, **kwargs) else: if kwargs.get('scatter', '') == 'True': kwargs['pen'] = None kwargs['symbol'] = self.used_symbols[ name] = self.avail_symbols.pop() kwargs['symbolPen'] = self.used_pens[ name] = self.avail_sym_pens.pop() kwargs['symbolBrush'] = self.used_brush[ name] = self.avail_sym_brush.pop() kwargs['symbolSize'] = 7 self.curves[name] = self.plot_widget.plot(*args, **kwargs) elif kwargs.get('scatter', '') == 'False': kwargs['pen'] = self.used_colors[name] = self.avail_colors.pop( ) self.curves[name] = self.plot_widget.plot(*args, **kwargs) del_action = QtWidgets.QAction(str(name), self) self.del_dict[del_action] = self.plot_widget.listDataItems()[-1] self.name_dict[del_action] = name del_action.triggered.connect( lambda: self.del_item(self.del_dict[del_action])) self.del_menu.addAction(del_action)
def __init__(self, plot_widget): self.plot_widget = plot_widget self.axis_size = 20 self.x_axis = [datetime.datetime.now().timestamp()] * self.axis_size self.y_axis = [0] * self.axis_size self.plot_widget.setAxisItems({"bottom": pyqtgraph.DateAxisItem()}) label_styles = {"color": "white", "font-size": "14px"} self.plot_widget.setLabel("left", "Face Size", **label_styles) # self.plot_widget.setLabel("bottom", "Time (timestamp)", **label_styles) self.data_plot = self.plot_widget.plot(self.x_axis, self.y_axis, symbol="+")
def __init__(self, parent=None): super(Avs47SingleChannelWidget, self).__init__(parent) self.dmm = None self.avs = None self.buffer = '' self.workerThread = None self.setupUi(self) self.setWindowTitle('AVS47 Single Channel') self.outputFile = None self.yaxisCombo.currentIndexChanged.connect(self.switchPlotAxis) self.temperatureIndicator.setPrecision(5) combo = self.calibrationCombo combo.addItem('RuOx 600') combo.addItem('RuOx 2005') combo.addItem('RuOx Bus (Shuo)') combo.setItemData(0, 'Nominal sensor calibration for RuOx 600 series', Qt.ToolTipRole) combo.setItemData(1, 'Calibration for RuOx sensor #2005 series', Qt.ToolTipRole) combo.setItemData( 2, 'Cross-calibration against RuOx #2005 by Shuo (not so good above ~300mK)', Qt.ToolTipRole) combo.currentIndexChanged.connect(self.selectCalibration) axis = pg.DateAxisItem(orientation='bottom') self.plot = pg.PlotWidget(axisItems={'bottom': axis}) self.plot.addLegend() self.verticalLayout.addWidget(self.plot) self.curve = pg.PlotCurveItem(name='Actual', symbol='o', pen='g') self.plot.addItem(self.curve) self.clearData() self.runPb.clicked.connect(self.runPbClicked) self.widgetsForSettings = [ self.readoutInternalRadio, self.readoutDmmRadio, self.readoutZmqRadio, self.bridgeCombo, self.dmmCombo, self.autoRangeCb, self.rangeUpSb, self.rangeDownSb, self.yaxisCombo, self.intervalSb, self.calibrationCombo ] self.restoreSettings() self.selectCalibration() #self.makeFilters() self.publisher = ZmqPublisher('Avs47SingleChannel', PubSub.AdrTemperature)
def __init__(self, parent=None): super(MagnetControlWidget, self).__init__(parent) self.setupUi(self) self.rampRateSb.valueChanged.connect(self.rampRateChanged) self.controlModeCombo.currentIndexChanged.connect( self.controlModeChanged) self.magnetThread = None axis = pg.DateAxisItem(orientation='bottom') self.plot = pg.PlotWidget(axisItems={'bottom': axis}) self.plot.setBackground('w') self.plot.plotItem.showGrid(x=True, y=True) self.verticalLayout_3.addWidget(self.plot) self.curve = pg.PlotCurveItem(name='Actual', symbol='o', pen='k') self.plot.addItem(self.curve) self.clearData() self.waveformPlot_.setBackground('w') self.waveformPlot_.showGrid(x=True, y=True) rawCurveLabels = [ u'Magnet voltage', u'FET output', u'Current coarse', u'Current fine' ] pens = 'krgb' self.rawCurves = {} self.waveformPlot_.addLegend() for i, label in enumerate(rawCurveLabels): curve = pg.PlotCurveItem(name=label, symbol='-', pen=pens[i % len(pens)]) self.rawCurves[label] = curve self.waveformPlot_.addItem(curve) yax = self.waveformPlot_.getAxis('left') yax.setLabel('Raw DAQ voltage') self.yaxisCombo.currentIndexChanged.connect(self.switchPlotAxis) self.switchPlotAxis() self.runPb.clicked.connect(self.run) self.magnetThread = None self.restoreSettings() self.fetVsdGoalSb.valueChanged.connect(self.updateFetVsd) self.fetVsdToleranceSb.valueChanged.connect(self.updateFetVsd) self.feedbackSlider.valueChanged.connect(self.updateFeedbackGain)
def drawing(self, graphicsView=None, canvas_setting=None, data=None): """ :param graphicsView: 绘图对象 :param canvas_setting: 绘图设置 :param data: 绘图数据 :return: """ if canvas_setting is None: canvas_setting = {} if data is None: data = [] if graphicsView is not None: graph = graphicsView.addPlot(axisItems={'bottom': pg.DateAxisItem(orientation='bottom')}, **canvas_setting) graph.addLegend() graph.showGrid(x=True, y=True) for data in data: graph.plot(**data)
def __init__(self): super(Graph,self).__init__() netLog.speedLog("Graph init") self.axisItems = {'bottom': pg.DateAxisItem()} self.plotList = {} self.placeList = [] self.colorRotation = 0 self.varList = [] self.varList.append("status") self.varList.append("clock(1)") self.varList.append("clock(2)") self.varList.append("clock(3)") self.varList.append("clock(4)") self.themeBack = "k" self.themeFore = "w" self.firstPlot = None #dafo211kd411da1 ip = os.environ.get('ICE_SERVER_IP', "localhost") port = os.environ.get('ICE_SERVER_PORT', 1431)
def __init__(self, parent=None): super(mainWindow, self).__init__(parent) self.setupUi(self) #set plot self.yAxisCombo.currentIndexChanged.connect(self.plotLabel) axis = pg.DateAxisItem(orientation='bottom') self.plot = pg.PlotWidget(axisItems={'bottom': axis}) self.verticalLayout.addWidget(self.plot) self.plot.addLegend() self.plot.setLabel('bottom', 'time') #connect self.clearPb.clicked.connect(self.clearData) self.StartAllPb.clicked.connect(self.startAll) self.StopAllPb.clicked.connect(self.stopAll) self.addRowPb.clicked.connect(self.addRow) self.deleteRowPb.clicked.connect(self.deleteRow) #set table self.rowCount = 0 self.tableWidget.setColumnCount(6) header = u'Enable,DMM VISA,Thermometer,Current (µA),Voltage,Temperature' self.tableWidget.setHorizontalHeaderLabels(header.split(',')) self.tableWidget.setColumnWidth(1, 150) self.tableWidget.setColumnWidth(2, 150) self.objectList = [] self.errorDisplayArray = [None for x in range(self.rowCount)] for i in range(self.errorDisplayArray.__len__()): self.errorDisplayTE.append(self.errorDisplayArray[i]) self.publisher = ZmqPublisher('DiodeThermometer', PubSub.DiodeThermometers) self.rowSelected = -1 self.settingsWidgets = [self.yAxisCombo] self.tableWidget.connect(self.tableWidget.verticalHeader(), SIGNAL("sectionClicked(int)"), self.selectRow) self.restoreSetting()
def __init__(self, parent=None): super(SR830_Widget, self).__init__(parent) self.setupUi(self) self.setWindowTitle('SR830 lock-in') self.timer = None self.selectFilePb.clicked.connect(self.selectFile) self.loggingEnableCb.toggled.connect(self.toggleLogging) self.loggingEnableCb.setEnabled(False) axis = pg.DateAxisItem(orientation='bottom') self.plot = pg.PlotWidget(axisItems={'bottom': axis}) self.plot.addLegend() self.verticalLayout.addWidget(self.plot) self.curve1 = pg.PlotCurveItem(name='X', symbol='o', pen='b') self.curve2 = pg.PlotCurveItem(name='Y', symbol='o', pen='r') self.curve3 = pg.PlotCurveItem(name='R', symbol='o', pen='g') self.plot.addItem(self.curve1) self.plot.addItem(self.curve2) self.plot.addItem(self.curve3) self.clearData() self.restoreSettings() self.logFileName = None self.sr830 = None self.controlPb.clicked.connect(self.control) #self.auxIn1Indicator.setUnit('V') #self.auxIn2Indicator.setUnit('V') #self.auxIn3Indicator.setUnit('V') #self.auxIn4Indicator.setUnit('V') self.rIndicator.setUnit('V') self.rIndicator.setPrecision(4) self.xIndicator.setUnit('V') self.xIndicator.setPrecision(4) self.yIndicator.setUnit('V') self.yIndicator.setPrecision(4) self.fIndicator.setUnit('Hz') self.clearPb.clicked.connect(self.clearData)
def _plot_prediction(self, historical_dfs: list[pd.DataFrame], model: RandomForest, prediction: ndarray, target_date: datetime.date) -> None: """Opens a window with a plot of the historical target data as well as the prediction the model made.""" hdf = historical_dfs[0] for frame in historical_dfs[1:]: hdf = hdf.combine_first(frame) window_end = target_date - \ pd.DateOffset(days=model.window.target_shift) window_start = window_end - pd.DateOffset(days=30 - 1) hdf = pd.Series( hdf.loc[window_end:window_start][model.window.target_lbl]) hdf_data = hdf.to_list() hdf_dates = hdf.index hdf_dates = [ts.to_pydatetime().timestamp() for ts in hdf_dates] b_axis = pg.DateAxisItem(orientation='bottom') b_axis.setLabel('Date') plot = PlotWidget(axisItems={'bottom': b_axis}) target_time = datetime.combine(target_date, datetime.min.time()) plot.addLegend() plot.plot(x=hdf_dates, y=hdf_data, name=f'Historical {model.window.target_lbl}') plot.plot(x=[target_time.timestamp()], y=prediction, pen=None, symbol='o', name=f'Predicted Value: {prediction[0]}') model_name = self._model.currentText() self._plot_window.setWindowTitle(f'{model_name} Prediction') self._plot_window.setCentralWidget(plot) self._plot_window.show()
def __init__(self, parent): self.db = parent.db self.dockArea = DockArea(parent) self.mouseIndex = "" self.dateFormat = self.getDateFormat("T") # Text and crosshair self.hLines = {} self.hTexts = {} self.vLines = {} self.vText = None # Candlestick init self.candlestick = CandlestickItem(self.db) self.volumeProfile = VolumeProfileItem(self.db) self.volumeProfile.onUpdate.connect(self.candlestick.update) self.candlestickWidget = pg.PlotWidget( self.dockArea, axisItems={"bottom": pg.DateAxisItem()}) self.candlestickWidget.addItem(self.candlestick) self.candlestickWidget.addItem(self.volumeProfile) self.addPlot("ohlc", self.candlestickWidget, 2)
def __init__(self): super().__init__() self.xaxis = pg.DateAxisItem() self.xaxis.setStyle(tickTextOffset=7, textFillLimits=[(0, 0.80)]) self.yaxis = PriceAxis() self.layout = QtGui.QVBoxLayout(self) self.layout.setContentsMargins(0, 0, 0, 0) self.chart = pg.PlotWidget( axisItems={'bottom': self.xaxis, 'right': self.yaxis}, enableMenu=False, ) self.chart.setFrameStyle(QtGui.QFrame.StyledPanel | QtGui.QFrame.Plain) self.chart.getPlotItem().setContentsMargins(*CHART_MARGINS) self.chart.showGrid(x=True, y=True) self.chart.hideAxis('left') self.chart.showAxis('right') self.chart.setCursor(QtCore.Qt.BlankCursor) self.chart.sigXRangeChanged.connect(self._update_yrange_limits) self.layout.addWidget(self.chart)