本文整理汇总了Python中guiqwt.plot.PlotManager.synchronize_axis方法的典型用法代码示例。如果您正苦于以下问题:Python PlotManager.synchronize_axis方法的具体用法?Python PlotManager.synchronize_axis怎么用?Python PlotManager.synchronize_axis使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类guiqwt.plot.PlotManager
的用法示例。
在下文中一共展示了PlotManager.synchronize_axis方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: synchronize_axis
# 需要导入模块: from guiqwt.plot import PlotManager [as 别名]
# 或者: from guiqwt.plot.PlotManager import synchronize_axis [as 别名]
def synchronize_axis(self, axis, plots=None):
if plots is None:
if axis in self.axis_syncplots:
plots = self.axis_syncplots[axis]
else:
plots = self.plots.keys()
if len(plots) < 1:
return
PlotManager.synchronize_axis(self, axis, plots)
# Find interval that needs to be shown in order to include all
# currently shown parts in the synchronized plots
plot_objects = [self.plots[p] for p in plots]
lb = min((p.axisScaleDiv(axis).lowerBound() for p in plot_objects))
ub = max((p.axisScaleDiv(axis).upperBound() for p in plot_objects))
for p in plot_objects:
p.setAxisScale(axis, lb, ub)
p.replot()
示例2: create_plot
# 需要导入模块: from guiqwt.plot import PlotManager [as 别名]
# 或者: from guiqwt.plot.PlotManager import synchronize_axis [as 别名]
def create_plot(self, options):
manager = PlotManager(None)
self.plotwidget = CurveWidget(self, manager=manager, **options)
manager.set_main(self.plotwidget)
plot1 = CurvePlot(title="TL")
plot2 = CurvePlot(title="TR")
plot3 = CurvePlot(title="BL")
plot4 = CurvePlot(title="BR")
self.plotwidget.add_plot(plot1, 0, 0, "1")
self.plotwidget.add_plot(plot2, 0, 1, "2")
self.plotwidget.add_plot(plot3, 1, 0, "3")
self.plotwidget.add_plot(plot4, 1, 1, "4")
self.plotwidget.finalize()
manager.synchronize_axis(BasePlot.X_BOTTOM, ["1", "3"])
manager.synchronize_axis(BasePlot.X_BOTTOM, ["2", "4"])
manager.synchronize_axis(BasePlot.Y_LEFT, ["1", "2"])
manager.synchronize_axis(BasePlot.Y_LEFT, ["3", "4"])
self.layout.addWidget(self.plotwidget, 0, 0)
示例3: synchronize_axis
# 需要导入模块: from guiqwt.plot import PlotManager [as 别名]
# 或者: from guiqwt.plot.PlotManager import synchronize_axis [as 别名]
def synchronize_axis(self, axis, plots = None):
if plots is None:
plots = self.plots.keys()
PlotManager.synchronize_axis(self, axis, plots)
示例4: PlottingHelper
# 需要导入模块: from guiqwt.plot import PlotManager [as 别名]
# 或者: from guiqwt.plot.PlotManager import synchronize_axis [as 别名]
class PlottingHelper(object):
'''This is the class implementing the plotting work.'''
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 update_curves(self, time, signals, interval_in_second):
'''update the curves everytime the signals change
time:
the time sequence, which is also the x_axis data
signal:
a dictionary of signals to plot, the keys of which is recorded
in self.signal_names.
and in fact these are the y_axis data
'''
xmax = time[-1]
xmin = max(xmax - interval_in_second, 0)
xdata = time
for list_name, sig_name_list in self.signal_names.items():
#
for i, sig_name in enumerate(sig_name_list):
#
ydata = signals[sig_name]
idxmn = int(xmin*self.sample_rate)
idxmx = int(xmax*self.sample_rate)
self.curve_items[sig_name].set_data(xdata[idxmn:idxmx], \
ydata[idxmn:idxmx])
self.curve_plots[list_name].do_autoscale()
示例5: RealtimeDemo
# 需要导入模块: from guiqwt.plot import PlotManager [as 别名]
# 或者: from guiqwt.plot.PlotManager import synchronize_axis [as 别名]
class RealtimeDemo(QWidget):
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 setup_toolbar(self):
toolbar = QToolBar()
self.auto_yrange_checkbox = QCheckBox(u"Y轴自动调节")
self.auto_xrange_checkbox = QCheckBox(u"X轴自动调节")
self.xrange_box = QSpinBox()
self.xrange_box.setMinimum(5)
self.xrange_box.setMaximum(50)
self.xrange_box.setValue(10)
self.auto_xrange_checkbox.setChecked(True)
self.auto_yrange_checkbox.setChecked(True)
toolbar.addWidget(self.auto_yrange_checkbox)
toolbar.addWidget(self.auto_xrange_checkbox)
toolbar.addWidget(self.xrange_box)
return toolbar
def timerEvent(self, event):
for i in xrange(100):
t = self.t
self.data[u"t"].append(t)
self.data[u"sin1f"].append(sin(t))
self.data[u"cos1f"].append(cos(t))
self.data[u"sin3f"].append(sin(3*t)/6)
self.data[u"cos3f"].append(cos(3*t)/6)
self.data[u"sin合成"].append(sin(t)+sin(3*t)/6)
self.data[u"cos合成"].append(cos(t)+cos(3*t)/6)
self.t += DT
if self.auto_xrange_checkbox.isChecked():
xmax = self.data["t"][-1]
xmin = max(xmax - self.xrange_box.value(), 0)
else:
xmin, xmax = self.plots[0].get_axis_limits('bottom')
for key, curve in self.curves.iteritems():
xdata = self.data["t"]
ydata = self.data[key]
x, y = get_peak_data(xdata, ydata, xmin, xmax, 600, 1/DT)
curve.set_data(x, y)
for plot in self.plots:
if self.auto_yrange_checkbox.isChecked() and self.auto_xrange_checkbox.isChecked():
plot.do_autoscale()
elif self.auto_xrange_checkbox.isChecked():
plot.set_axis_limits("bottom", xmin, xmax)
plot.replot()
else:
plot.replot()
示例6: SyncXAxis
# 需要导入模块: from guiqwt.plot import PlotManager [as 别名]
# 或者: from guiqwt.plot.PlotManager import synchronize_axis [as 别名]
class SyncXAxis(QtGui.QWidget):
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 setup_toolbar(self):
toolbar = QtGui.QGridLayout()
self.auto_xrange_checkbox = QtGui.QCheckBox(u"X轴自动调节")
self.xrange_box = QtGui.QSpinBox()
self.xrange_box.setMinimum(5)
self.xrange_box.setMaximum(100)
self.xrange_box.setValue(50)
self.auto_xrange_checkbox.setChecked(True)
self.Roll_label = QtGui.QLabel("PID KP:")
self.lineEdit1 = QtGui.QLineEdit()
self.lineEdit1.setText("1")
self.lineEdit1.returnPressed.connect(self.PID_Roll)
self.Roll_label.setBuddy(self.lineEdit1)
self.Pitch_label = QtGui.QLabel("PID KI:")
self.lineEdit2 = QtGui.QLineEdit()
self.Pitch_label.setBuddy(self.lineEdit2)
self.lineEdit2.setText("1")
self.lineEdit2.returnPressed.connect(self.PID_Pitch)
self.Yaw_label = QtGui.QLabel("PID KD:")
self.lineEdit3 = QtGui.QLineEdit()
self.Yaw_label.setBuddy(self.lineEdit3)
self.lineEdit3.setText("1")
self.lineEdit3.returnPressed.connect(self.PID_Yaw)
toolbar.addWidget(self.auto_xrange_checkbox,0,0)
toolbar.addWidget(self.xrange_box,0,1)
toolbar.addWidget(self.Roll_label,1,0)
toolbar.addWidget(self.lineEdit1,1,1)
toolbar.addWidget(self.Pitch_label,2,0)
toolbar.addWidget(self.lineEdit2,2,1)
toolbar.addWidget(self.Yaw_label,3,0)
toolbar.addWidget(self.lineEdit3,3,1)
return toolbar
def PID_Roll(self):
global RPY_Array
try:
#print str(int(self.lineEdit1.text()))
RPY_Array[0] = int(self.lineEdit1.text())
except:
pass
def PID_Pitch(self):
global RPY_Array
try:
#print str(self.lineEdit1.text())
RPY_Array[1] = int(self.lineEdit2.text())
#.........这里部分代码省略.........