def __init__(self): super(RealtimeDemo, self).__init__() self.setWindowTitle(u"Realtime Demo") self.data = {u"t":array("d")} for name in sum(PLOT_DEFINE, []): self.data[name] = array("d") self.curves = {} self.t = 0 vbox = QVBoxLayout() vbox.addWidget(self.setup_toolbar()) self.manager = PlotManager(self) self.plots = [] for i, define in enumerate(PLOT_DEFINE): plot = CurvePlot() plot.axisScaleDraw(CurvePlot.Y_LEFT).setMinimumExtent(60) self.manager.add_plot(plot) self.plots.append(plot) plot.plot_id = id(plot) for j, curve_name in enumerate(define): curve = self.curves[curve_name] = make.curve([0], [0], color=COLORS[j], title=curve_name) plot.add_item(curve) plot.add_item(make.legend("BL")) vbox.addWidget(plot) self.manager.register_standard_tools() self.manager.get_default_tool().activate() self.manager.synchronize_axis(CurvePlot.X_BOTTOM, self.manager.plots.keys()) self.setLayout(vbox) self.startTimer(100)
def __init__(self): super(RealtimeDemo, self).__init__() self.setWindowTitle(u"Realtime Demo") self.data = {u"t": array("d")} for name in sum(PLOT_DEFINE, []): self.data[name] = array("d") self.curves = {} self.t = 0 vbox = QVBoxLayout() vbox.addWidget(self.setup_toolbar()) self.manager = PlotManager(self) self.plots = [] for i, define in enumerate(PLOT_DEFINE): plot = CurvePlot() plot.axisScaleDraw(CurvePlot.Y_LEFT).setMinimumExtent(60) self.manager.add_plot(plot) self.plots.append(plot) plot.plot_id = id(plot) for j, curve_name in enumerate(define): curve = self.curves[curve_name] = make.curve([0], [0], color=COLORS[j], title=curve_name) plot.add_item(curve) plot.add_item(make.legend("BL")) vbox.addWidget(plot) self.manager.register_standard_tools() self.manager.get_default_tool().activate() self.manager.synchronize_axis(CurvePlot.X_BOTTOM, self.manager.plots.keys()) self.setLayout(vbox) self.startTimer(100)
def __init__(self): super(SyncXAxis, self).__init__() self.data = {u"t":array("d")} for name in sum(PLOT_DEFINE, []): self.data[name] = array("d") self.i = 0 self.x = [] self.curves = {} self.t = 0 self.sint = [] self.get_Roll = [] self.get_Pitch = [] self.get_Yaw = [] self.get_Angle1 = [] self.get_Angle2 =[] self.get_Angle3 = [] vbox = QtGui.QGridLayout() #工具栏 vbox.addLayout(self.setup_toolbar(),0,0) self.manager = PlotManager(self) self.plots = [] #生成竖直排列图形窗口 for i, define in enumerate(PLOT_DEFINE): plot = CurvePlot() plot.axisScaleDraw(CurvePlot.Y_LEFT).setMinimumExtent(60) self.manager.add_plot(plot) self.plots.append(plot) plot.plot_id = id(plot) for j, curve_name in enumerate(define): curve = self.curves[curve_name] = make.curve([0], [0], color=COLORS[j], title=curve_name) plot.add_item(curve) plot.add_item(make.legend("BL")) #vbox.addWidget(plot) vbox.addWidget(self.plots[0],1,0) vbox.addWidget(self.plots[1],1,1) vbox.addWidget(self.plots[2],2,0) vbox.addWidget(self.plots[3],2,1) self.manager.register_standard_tools() self.manager.get_default_tool().activate() self.manager.synchronize_axis(CurvePlot.X_BOTTOM, self.manager.plots.keys()) self.setLayout(vbox) self.startTimer(20)
def Plot_Start_New(widget,PLOT_DEFINE,COLORS,x1,x2,y1,y2): newmanager = PlotManager(widget) newplots = [] newcurves = {} for name in PLOT_DEFINE: plot = CurvePlot() #设置图表颜色 plot.setStyleSheet('''QWidget{ border: 1px solid #32435E; border-radius: 3px; font-size:11pt; color:white; font-family:"Microsoft YaHei UI"; /* padding: 0 8px; */ background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #080B10, stop: 1.0 #212C3F); selection-background-color: #0A246A; } ''' ) plot.axisScaleDraw(CurvePlot.Y_LEFT).setMinimumExtent(20) newplots.append(plot) newmanager.add_plot(plot) plot.plot_id = id(plot) for curve_color, curve_name in map(None,COLORS,name): if u"状态" in curve_name or u"打角/100" in curve_name : newcurves[curve_name] = guiqwt_make.curve([0], [0],markerfacecolor = 'black', markeredgecolor=curve_color, title=curve_name,marker = 'Diamond',linestyle = 'NoPen',markersize = 6) else: newcurves[curve_name] = guiqwt_make.curve([0], [0], color=curve_color, title=curve_name) plot.add_item(newcurves[curve_name]) #设置X轴y轴 plot.set_axis_limits(newcurves[curve_name].yAxis(),y1,y2) plot.set_axis_limits(newcurves[curve_name].xAxis(),x1,x2) plot.add_item(guiqwt_make.legend("BL")) newmanager.register_standard_tools() newmanager.get_default_tool().activate() return (newmanager,newplots,newcurves)
def __init__(self, parent, signal_names, sample_rate): '''Do the initialization work. A PlottingHelper object helps plotting a group of signals all of which has the same number of points to plot at one time. signal_names: a dictionary {'list_name':['list of signal names']} sample_rate: the sample_rate of the signals ''' self.sample_rate = sample_rate self.signal_names = signal_names self.curve_items = {} self.curve_plots = {} self.plot_manager = PlotManager(parent) for list_name, sig_name_list in self.signal_names.items(): # One CurvePlot object for every sig_name_list curve_plot = CurvePlot() curve_plot.axisScaleDraw(CurvePlot.Y_LEFT).setMinimumExtent(10) self.curve_plots[list_name] = curve_plot curve_plot.plot_id = id(curve_plot) for i, sig_name in enumerate(sig_name_list): # One CurveItem object for every signal_name print sig_name, colors[i] self.curve_items[sig_name] = make.curve([0], [0], \ color=colors[i], title=sig_name) curve_plot.add_item(self.curve_items[sig_name]) # add the curve_plot object to plot_manager self.plot_manager.add_plot(curve_plot) # register and activate the tools self.plot_manager.register_standard_tools() self.plot_manager.get_default_tool().activate() self.plot_manager.synchronize_axis(CurvePlot.X_BOTTOM, \ self.plot_manager.plots.keys())
def __init__(self): super(RealtimeDemo, self).__init__() self.setWindowTitle(u"Realtime Demo") self.data = {u"t":array("d")} # for name in sum(PLOT_DEFINE, []): # self.data[name] = array("d") for name in PLOT_DEFINE: self.data[name] = array("d") self.curves = {} self.t = 0 vbox = QVBoxLayout() vbox.addWidget(self.setup_toolbar()) grid = QGridLayout() vbox.addLayout(grid) self.manager = PlotManager(self) self.plots = [] # for i, define in enumerate(PLOT_DEFINE): # plot = CurvePlot() # plot.axisScaleDraw(CurvePlot.Y_LEFT).setMinimumExtent(60) # self.manager.add_plot(plot) # self.plots.append(plot) # plot.plot_id = id(plot) # for j, curve_name in enumerate(define): # curve = self.curves[curve_name] = make.curve([0], [0], color=COLORS[j], title=curve_name) # plot.add_item(curve) # plot.add_item(make.legend("BL")) # vbox.addWidget(plot) # self.manager.register_standard_tools() # self.manager.get_default_tool().activate() # self.manager.synchronize_axis(CurvePlot.X_BOTTOM, self.manager.plots.keys()) # self.setLayout(vbox) # self.startTimer(100) # buttton_names = ['Cls', 'Bck', '', 'Close', # '7', '8', '9', '/', # '4', '5', '6', '*', # '1', '2', '3', '-', # '0', '.', '=', '+'] # main_ground = QtWidgets.QWidget() # self.setCentralWidget(main_ground) # grid = QtWidgets.QGridLayout() # for [n, (x, y)] in enumerate([(i, j) for i in range(4) for j in range(4)]): plot = CurvePlot() plot.axisScaleDraw(CurvePlot.Y_LEFT).setMinimumExtent(60) self.manager.add_plot(plot) self.plots.append(plot) plot.plot_id = id(plot) curve = self.curves[PLOT_DEFINE[n]] = make.curve([0], [0], color=COLORS[0], title=PLOT_DEFINE[n]) plot.add_item(curve) plot.add_item(make.legend("BL")) grid.addWidget(plot, x, y) self.manager.register_standard_tools() self.manager.get_default_tool().activate() self.manager.synchronize_axis(CurvePlot.X_BOTTOM, self.manager.plots.keys()) self.setLayout(vbox) self.startTimer(100)