本文整理汇总了Python中guiqwt.plot.PlotManager.add_plot方法的典型用法代码示例。如果您正苦于以下问题:Python PlotManager.add_plot方法的具体用法?Python PlotManager.add_plot怎么用?Python PlotManager.add_plot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类guiqwt.plot.PlotManager
的用法示例。
在下文中一共展示了PlotManager.add_plot方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: CentralWidget
# 需要导入模块: from guiqwt.plot import PlotManager [as 别名]
# 或者: from guiqwt.plot.PlotManager import add_plot [as 别名]
class CentralWidget(QWidget):
def __init__(self, parent):
QWidget.__init__(self, parent)
layout = QGridLayout()
self.setLayout(layout)
self.plot1 = ImagePlot(self)
layout.addWidget(self.plot1, 0, 0, 1, 1)
self.plot2 = ImagePlot(self)
layout.addWidget(self.plot2, 1, 0, 1, 1)
self.contrast = ContrastAdjustment(self)
layout.addWidget(self.contrast, 2, 0, 1, 2)
self.itemlist = PlotItemList(self)
layout.addWidget(self.itemlist, 0, 1, 2, 1)
self.manager = PlotManager(self)
for plot in (self.plot1, self.plot2):
self.manager.add_plot(plot)
for panel in (self.itemlist, self.contrast):
self.manager.add_panel(panel)
def register_tools(self):
self.manager.register_all_image_tools()
示例2: configure_plot
# 需要导入模块: from guiqwt.plot import PlotManager [as 别名]
# 或者: from guiqwt.plot.PlotManager import add_plot [as 别名]
def configure_plot(self):
self.marker = add_marker(self.plot)
self.line = MeasurementLine()
self.line.setVisible(0)
self.label = make_label(self.marker, self.line)
setupCommonStyle(self.line, self.marker)
manager = PlotManager(self.widget)
manager.add_plot(self.plot)
tool = manager.add_tool(MzSelectionTool)
tool.activate()
manager.set_default_tool(tool)
self.plot.add_item(self.marker)
self.plot.add_item(self.label)
self.plot.add_item(self.line)
self.plot.startMeasuring.connect(self.line.start_measuring)
self.plot.moveMeasuring.connect(self.line.move_measuring)
self.plot.stopMeasuring.connect(self.line.stop_measuring)
self.plot.moveMarker.connect(self.marker.move_local_point_to)
self.line.updated.connect(self.plot.replot)
示例3: iScope
# 需要导入模块: from guiqwt.plot import PlotManager [as 别名]
# 或者: from guiqwt.plot.PlotManager import add_plot [as 别名]
class iScope(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
self.setWindowTitle("iScope (TM)")
hlayout = QHBoxLayout()
central_widget = QWidget(self)
central_widget.setLayout(hlayout)
self.setCentralWidget(central_widget)
# ---guiqwt plot manager
self.manager = PlotManager(self)
# ---
def add_plot(self, x, y):
widget = iScopeWidget(self, x, y)
widget.setup_widget()
self.centralWidget().layout().addWidget(widget)
# ---Register plot to manager
self.manager.add_plot(widget.plot)
# ---
def setup_window(self):
# ---Add toolbar and register manager tools
toolbar = self.addToolBar("tools")
self.manager.add_toolbar(toolbar, id(toolbar))
self.manager.register_standard_tools()
self.manager.tools[0].activate()
示例4: TestWindow
# 需要导入模块: from guiqwt.plot import PlotManager [as 别名]
# 或者: from guiqwt.plot.PlotManager import add_plot [as 别名]
class TestWindow(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
self.setWindowTitle("Signal filtering 2 (guiqwt)")
self.setWindowIcon(get_icon('guiqwt.svg'))
hlayout = QHBoxLayout()
central_widget = QWidget(self)
central_widget.setLayout(hlayout)
self.setCentralWidget(central_widget)
#---guiqwt plot manager
self.manager = PlotManager(self)
#---
def add_plot(self, x, y, func, title):
widget = FilterTestWidget(self, x, y, func)
widget.setup_widget(title)
self.centralWidget().layout().addWidget(widget)
#---Register plot to manager
self.manager.add_plot(widget.plot)
#---
def setup_window(self):
#---Add toolbar and register manager tools
toolbar = self.addToolBar("tools")
self.manager.add_toolbar(toolbar, id(toolbar))
self.manager.register_all_curve_tools()
示例5: Plot_Start_New
# 需要导入模块: from guiqwt.plot import PlotManager [as 别名]
# 或者: from guiqwt.plot.PlotManager import add_plot [as 别名]
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)
示例6: TestDialog
# 需要导入模块: from guiqwt.plot import PlotManager [as 别名]
# 或者: from guiqwt.plot.PlotManager import add_plot [as 别名]
class TestDialog(QDialog):
def __init__(self):
QDialog.__init__(self)
vlayout = QVBoxLayout()
self.setLayout(vlayout)
self.widget = CurveWidget()
self.curve_item = make.curve([], [], color='r')
self.widget.plot.add_item(self.curve_item)
self.pm = PlotManager(self.widget)
self.pm.add_plot(self.widget.plot)
t = self.pm.add_tool(MyTool)
t.curve_item = self.curve_item
self.pm.set_default_tool(t)
t.activate()
self.layout().addWidget(self.widget)
self.update_curve()
def update_curve(self):
x = np.arange(0,10,.1)
y = np.sin(np.sin(x))
self.curve_item.set_data(x, y)
self.curve_item.plot().replot()
示例7: GuiQwtPlot
# 需要导入模块: from guiqwt.plot import PlotManager [as 别名]
# 或者: from guiqwt.plot.PlotManager import add_plot [as 别名]
class GuiQwtPlot( QtGui.QMainWindow ):
def __init__( self ):
QtGui.QMainWindow.__init__( self )
self.__create_layout()
self.__setup_layout()
def __create_layout( self ):
self.setWindowTitle( "Live *.Chi plotter, v. 2.1.0 (April 2013)" )
self.plot = CurvePlot( self )
self.plot.set_antialiasing( True )
self.plot2 = CurvePlot( self )
self.plot2.set_antialiasing( True )
self.button = QtGui.QPushButton( "Search for files" )
self.button2 = QtGui.QPushButton( "Plot selected files" )
self.button3 = QtGui.QPushButton( "Select all" )
self.button4 = QtGui.QPushButton( "Select none" )
self.button5 = QtGui.QPushButton( "Integrate" )
self.button6 = QtGui.QPushButton( "Integral over ROI (defined by the two vertical cursors)" )
left_hbox0 = QtGui.QVBoxLayout()
right_hbox0 = QtGui.QVBoxLayout()
# Main graph
left_vbox = QtGui.QVBoxLayout()
left_vbox.addWidget( self.plot, 3)
# Smaller graph
left_vbox.addWidget( self.plot2, 1 )
self.tick_axis_reset = QtGui.QCheckBox("Reset axis when replotting data")
self.tick_axis_reset.setCheckState(Qt.Checked)
left_hbox0.addWidget( self.tick_axis_reset )
# Static text field
right_hbox0.addWidget( QtGui.QLabel('Directory'), 0, QtCore.Qt.AlignRight )
hbox0 = QtGui.QHBoxLayout()
hbox0.addLayout( left_hbox0 )
hbox0.addLayout( right_hbox0 )
left_vbox.addLayout( hbox0 )
# Add buttons to the left side
left_vbox.addWidget( self.button )
left_vbox.addWidget( self.button2 )
left_vbox.addWidget( self.button6 )
# Data series list view
log_label = QtGui.QLabel("Data series:")
self.series_list_model = QtGui.QStandardItemModel()
self.series_list_view = QtGui.QListView()
self.series_list_view.setModel(self.series_list_model)
right_vbox = QtGui.QVBoxLayout()
right_vbox.addWidget( log_label )
right_vbox.addWidget( self.series_list_view )
# Create editable text box for inputting directory
self.text1 = QtGui.QTextEdit()
self.text1.setFixedHeight(22)
# Put current directory to the text box
self.text1.setText(os.getcwd())
right_vbox.addWidget( self.text1 )
# Add buttons
right_vbox.addWidget( self.button3 )
right_vbox.addWidget( self.button4 )
right_vbox.addWidget( self.button5 )
# Combine left and right box
hbox = QtGui.QHBoxLayout()
hbox.addLayout( left_vbox, 2 ) # Second parameter is the stretch factor
hbox.addLayout( right_vbox, 1 ) # of the widget, letting the figure to stretch more
w = QtGui.QWidget()
w.setLayout( hbox )
self.setCentralWidget( w )
def __setup_layout( self ):
self.connect( self.button, QtCore.SIGNAL( 'clicked()' ), self.button_Click )
self.connect( self.button2, QtCore.SIGNAL( 'clicked()' ), self.button_Click2 )
self.connect( self.button3, QtCore.SIGNAL( 'clicked()' ), self.button_Click3 )
self.connect( self.button4, QtCore.SIGNAL( 'clicked()' ), self.button_Click4 )
self.connect( self.button5, QtCore.SIGNAL( 'clicked()' ), self.button_Click5 )
self.connect( self.button6, QtCore.SIGNAL( 'clicked()' ), self.button_Click6 )
# Vertical cursor
self.cursorposition = 0.8
self.cursorposition2 = 1.2
self.vcursor1 = make.vcursor(self.cursorposition, label='x = %.2f')
self.plot.add_item( self.vcursor1 )
self.vcursor2 = make.vcursor(self.cursorposition2, label='x = %.2f')
self.plot.add_item( self.vcursor2 )
# Define the y label, x might change depending on user definition
CurvePlot.set_axis_title(self.plot,CurvePlot.Y_LEFT,"Intensity (counts)")
# Crate the PlotManager
self.manager = PlotManager( self )
self.manager.add_plot( self.plot )
#.........这里部分代码省略.........
示例8: EicPlottingWidget
# 需要导入模块: from guiqwt.plot import PlotManager [as 别名]
# 或者: from guiqwt.plot.PlotManager import add_plot [as 别名]
class EicPlottingWidget(CurveWidget):
SELECTED_RANGE_CHANGED = pyqtSignal(float, float)
def __init__(self, parent=None, with_range=True):
super(EicPlottingWidget, self).__init__(parent, ylabel="I")
patch_inner_plot_object(self, EicPlot)
self._with_range = with_range
self._setup_plot()
def enable_range(self, flag):
self._with_range = flag
self._setup_range_selector()
def _setup_plot(self):
self.pm = PlotManager(self)
self.pm.add_plot(self.plot)
t = self.pm.add_tool(RtSelectionTool)
t.activate()
self.pm.set_default_tool(t)
self._setup_cursor()
self._setup_range_selector()
self._setup_label()
self._setup_axes()
def _setup_cursor(self):
marker = Marker(label_cb=self.plot.label_info, constraint_cb=self.plot.on_plot)
marker.rts = [0]
setup_marker_param(marker, {"symbol.size": 0,
"symbol.alpha": 0.0,
"sel_symbol.size": 0,
"sel_symbol.alpha": 0.0,
"line.color": "#909090",
"line.width": 1.0,
"line.style": "SolidLine",
"sel_line.color": "#909090",
"sel_line.width": 1.0,
"sel_line.style": "SolidLine",
"markerstyle": "VLine"})
marker.attach(self.plot)
self.marker = marker
self._setup_cursor_info(marker)
def _setup_cursor_info(self, marker):
self.cursor_info = RtCursorInfo(marker)
def _setup_range_selector(self):
if not self._with_range:
self.range_ = None
return
self.range_ = SnappingRangeSelection(0, 0)
# you have to register item to plot before you can register the
# rtSelectionHandler:
self.plot.add_item(self.range_)
self.range_.SELECTED_RANGE_CHANGED.connect(self._range_selection_handler)
cc = make.info_label("TR", [RangeSelectionInfo(self.range_)], title=None)
setup_label_param(cc, {"label": "", "font.size": 12})
self.plot.add_item(cc)
def _setup_label(self):
label = make.info_label("T", [self.cursor_info], title=None)
setup_label_param(label, {"label": "", "font.size": 12, "border.color": "#ffffff"})
self.label = label
def _setup_axes(self):
# render tic labels in modfied format:
set_rt_formatting_on_x_axis(self.plot)
self.plot.set_axis_title("bottom", "RT")
def plot_(self, eics):
self.add_eics(eics)
def set_cursor_pos(self, rt):
self.plot.set_rt(rt)
def set_overall_range(self, rtmin, rtmax):
self.plot.overall_x_min = rtmin
self.plot.overall_x_max = rtmax
def add_eics(self, data, labels=None, configs=None):
""" do not forget to call replot() after calling this function ! """
allrts = list()
if configs is None:
configs = [{"color": getColor(i)} for i in range(len(data))]
if labels is None:
labels = [""] * len(data)
unique_labels = set()
# items_with_label = []
seen = set()
for i, (rts, chromatogram) in enumerate(data):
# we do not plot duplicates, which might happen if multiple lines in the
#.........这里部分代码省略.........
示例9: Ui_Form
# 需要导入模块: from guiqwt.plot import PlotManager [as 别名]
# 或者: from guiqwt.plot.PlotManager import add_plot [as 别名]
class Ui_Form(object):
def __init__(self, type):
self.dc = DataController()
self.drc = RepresentationControl()
self.flowData = self.dc.abstractionData
pos = self.drc.getAvailableAlgorithms().keys().index(type)
self.drc.selectAlgorithm(pos)
def setupUi(self, Form):
Form.setObjectName(_fromUtf8("Form"))
Form.resize(536, 384)
self.tableWidget = QtGui.QTableWidget(Form)
self.tableWidget.setGeometry(QtCore.QRect(90, 261, 221, 121))
if self.dc.getCurrentLabels() is None:
QtGui.QMessageBox.warning(Form, "No Features Found", "Please select Feature Extraction Method first",
QtGui.QMessageBox.Ok)
self.tableWidget.setObjectName(_fromUtf8("tableWidget"))
self.tableWidget.setColumnCount(2)
self.tableWidget.setRowCount(len(list(set(self.dc.getCurrentLabels()))))
self.pushButton = QtGui.QPushButton(Form)
self.pushButton.setGeometry(QtCore.QRect(0, 360, 75, 23))
self.pushButton.setObjectName(_fromUtf8("pushButton"))
self.label = QtGui.QLabel(Form)
self.label.setGeometry(QtCore.QRect(10, 10, 521, 211))
self.label.setText("The state figure will be saved")
self.widget = QtGui.QWidget()
self.widget.setGeometry(QtCore.QRect(10, 10, 521, 211))
self.widget.setObjectName(_fromUtf8("widget"))
self.dialog = CurveDialog(edit=False, toolbar=False, parent=self.widget)
self.plot = self.dialog.get_plot()
self.plot.set_antialiasing(True)
self.plot.setAxisTitle(Qwt5.Qwt.QwtPlot.xBottom, 'Time')
self.plot.setAxisTitle(Qwt5.Qwt.QwtPlot.yLeft, 'Value')
self.manager = PlotManager(self)
self.manager.add_plot(self.plot)
ly = QtGui.QVBoxLayout()
ly.addWidget(QtGui.QLabel(self.widget))
ly.addWidget(QtGui.QLabel(self.plot))
self.widget.setLayout(ly)
# item = QtGui.QTableWidgetItem()
# self.tableWidget.setHorizontalHeaderItem(0, item)
# item = QtGui.QTableWidgetItem()
# self.tableWidget.setItem(0, 0, item)
# item = QtGui.QTableWidgetItem()
# self.tableWidget.setItem(0, 1, item)
# item = self.tableWidget.horizontalHeaderItem(0)
# item.setText(_translate("Form", "Attribute", None))
c = 0
for it in list(set(self.dc.getCurrentLabels())):
# item = QtGui.QTableWidgetItem()
# item.setText(_translate("Form", "Id" + str(c), None))
# self.tableWidget.setVerticalHeaderItem(c, item)
item = QtGui.QTableWidgetItem()
item.setText(str(it))
self.tableWidget.setItem(c, 0, item)
#print "jgaboo timeig", it
#print it, self.drc.getRequiredParameters()[it]
item = QtGui.QTableWidgetItem()
item.setText("States!")
self.tableWidget.setItem(c, 1, item)
#print c
c += 1
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
def retranslateUi(self, Form):
Form.setWindowTitle(_translate("Form", "Form", None))
__sortingEnabled = self.tableWidget.isSortingEnabled()
self.tableWidget.setSortingEnabled(False)
self.tableWidget.setSortingEnabled(__sortingEnabled)
self.pushButton.setText(_translate("Form", "Picture It!", None))
Form.connect(self.pushButton, QtCore.SIGNAL('clicked()'), self.processor)
def processor(self):
print "in process"
params = {}
for i in range(self.tableWidget.rowCount()):
a = self.tableWidget.item(i, 0)
b = self.tableWidget.item(i, 1)
params[str(a.text())] = str(b.text())
#print "paramsjo", params
#print "paramsjo2", self.dc.params
self.drc.represent(None,{"states":self.dc.params})
示例10: Ui_PlotWidget_Reduce_Set
# 需要导入模块: from guiqwt.plot import PlotManager [as 别名]
# 或者: from guiqwt.plot.PlotManager import add_plot [as 别名]
class Ui_PlotWidget_Reduce_Set(QtGui.QWidget):
""""""
def __init__(self, parent=None):
"""Constructor for Ui_PlotWidget"""
QtGui.QWidget.__init__(self, parent)
self.setupUi()
def setupUi(self):
"""loads numpy array
Args:
self
Returns:
nothing
"""
#self.plot = CurvePlot(self)
self.dialog = CurveDialog(edit=False, toolbar=True, parent=self)
self.plot = self.dialog.get_plot()
self.plot.set_antialiasing(True)
#x = np.linspace(-10,10,200)
#dy = x/100.
#y = np.sin(np.sin(np.sin(x)))
#self.plot.add_item(make.curve(x,y))
self.loadButton = QtGui.QPushButton("Load")
self.trainButton = QtGui.QPushButton("Train Model")
ly = QtGui.QVBoxLayout()
ly.addWidget(self.plot)
#ly.addWidget(self.loadButton)
#ly.addWidget(self.trainButton)
self.plot.setAxisTitle(Qwt5.Qwt.QwtPlot.xBottom, 'Time')
self.plot.setAxisTitle(Qwt5.Qwt.QwtPlot.yLeft, 'Value')
self.manager = PlotManager(self)
self.manager.add_plot(self.plot)
#self.manager.
legend = make.legend('TL')
self.plot.add_item(legend)
self.setLayout(ly)
self.move(300, 200)
self.show()
self.dataController = DataController.DataController()
def loadData(self):
self.trainingData = self.dataController.loadSampleData()
import logic.DimensionalityReduceControl as controller
c = controller.DimensionalityReduceControl()
c.selectAlgorithm(2)
outpN = 100
params = {"none": "none", "output_length": outpN}
data = c.reduceData(self.trainingData["PIR"][:],params)
print data
self.plot.add_item(make.curve(range(0, len(data)), data))
self.rangeSelection = make.range(-2, 2)
disp0 = make.range_info_label(self.rangeSelection, 'BR', u"x = %.1f +- %.1f cm",
title="Range infos")
self.plot.add_item(self.rangeSelection)
self.plot.add_item(disp0)
self.plot.replot()
def trainData(self,string_length, vocab, window_length, clusterN):
a, b = self.rangeSelection.get_range()
if a > b:
a, b = b, a
print a, b
print "in widget", int(string_length), int(vocab), int(window_length), int(clusterN)
self.dataController.trainData(a,b,int(string_length), int(vocab), int(window_length), int(clusterN))
示例11: RtPlotter
# 需要导入模块: from guiqwt.plot import PlotManager [as 别名]
# 或者: from guiqwt.plot.PlotManager import add_plot [as 别名]
class RtPlotter(PlotterBase):
def __init__(self, rangeSelectionCallback=None):
super(RtPlotter, self).__init__("RT", "I")
self.rangeSelectionCallback = rangeSelectionCallback
widget = self.widget
widget.plot.__class__ = RtPlot
# todo: refactor as helper
a = QwtScaleDraw()
# render tic labels in modfied format:
label = lambda self, v: QwtText(formatSeconds(v))
a.label = new.instancemethod(label, widget.plot, QwtScaleDraw)
widget.plot.setAxisScaleDraw(widget.plot.xBottom, a)
self.pm = PlotManager(widget)
self.pm.add_plot(widget.plot)
t = self.pm.add_tool(RtSelectionTool)
self.addTool(RtSelectionTool)
self.pm.set_default_tool(t)
marker = Marker(label_cb=self.widget.plot.label_info,
constraint_cb=self.widget.plot.on_plot)
marker.rts = [0]
setupStyleRtMarker(marker)
marker.attach(self.widget.plot)
self.marker = marker
label = make.info_label("T", [RtCursorInfo(marker)], title=None)
label.labelparam.label = ""
self.label = label
self.minRTRangeSelected = None
self.maxRTRangeSelected = None
def addTool(self, tool):
t = self.pm.add_tool(tool)
t.activate()
def reset(self):
self.plot([])
self.marker.rts = [0]
self.replot()
def plot(self, chromatograms, titles=None, configs=None,
withmarker=False):
""" do not forget to call replot() after calling this function ! """
allrts = set()
self.widget.plot.del_all_items()
# self.widget.plot.set_antialiasing(True)
for i in range(len(chromatograms)):
rts, chromatogram = chromatograms[i]
config = None
if configs is not None:
config = configs[i]
if config is None:
config = dict(color=getColor(i))
if titles:
title = titles[i]
else:
title = ""
curve = make.curve(rts, chromatogram, title=title, **config)
curve.__class__ = ModifiedCurveItem
allrts.update(rts)
self.widget.plot.add_item(curve)
if withmarker:
self.widget.plot.add_item(self.label)
allrts = sorted(allrts)
self.marker.rts = allrts
self.marker.attach(self.widget.plot)
self.widget.plot.add_item(self.marker)
if titles is not None:
self.widget.plot.add_item(make.legend("TL"))
self.addRangeSelector(allrts)
def setEnabled(self, enabled):
self.widget.plot.setVisible(enabled)
def addRangeSelector(self, rtvalues):
self.rtvalues = rtvalues
self.minRTRangeSelected = 0
self.maxRTRangeSelected = 0
range_ = SnappingRangeSelection(self.minRTRangeSelected,
self.maxRTRangeSelected, self.rtvalues)
setupStyleRangeMarker(range_)
self.range_ = range_
# you have to register item to plot before you can register the
# rtSelectionHandler:
self.widget.plot.add_item(range_)
self.widget.disconnect(range_.plot(), SIG_RANGE_CHANGED,
self.rangeSelectionHandler)
self.widget.connect(range_.plot(), SIG_RANGE_CHANGED,
#.........这里部分代码省略.........
示例12: MzPlotter
# 需要导入模块: from guiqwt.plot import PlotManager [as 别名]
# 或者: from guiqwt.plot.PlotManager import add_plot [as 别名]
class MzPlotter(PlotterBase):
def __init__(self, c_callback=None, image_plot=None):
super(MzPlotter, self).__init__("m/z", "I")
self.c_callback = c_callback
widget = self.widget
# inject mofified behaviour of wigets plot attribute:
widget.plot.__class__ = MzPlot
widget.plot.register_c_callback(self.handle_c_pressed)
widget.plot.image_plot = image_plot
self.setHalfWindowWidth(0.05)
self.centralMz = None
# todo: refactor as helper
a = QwtScaleDraw()
label = lambda self, x: QwtText("%s" % x)
a.label = new.instancemethod(label, widget.plot, QwtScaleDraw)
widget.plot.setAxisScaleDraw(widget.plot.xBottom, a)
self.pm = PlotManager(widget)
self.pm.add_plot(widget.plot)
self.curve = make.curve([], [], color='b', curvestyle="Sticks")
# inject modified behaviour:
self.curve.__class__ = ModifiedCurveItem
self.widget.plot.add_item(self.curve)
t = self.pm.add_tool(MzSelectionTool)
self.pm.set_default_tool(t)
t.activate()
marker = Marker(label_cb=widget.plot.label_info,
constraint_cb=widget.plot.on_plot)
marker.attach(self.widget.plot)
line = make.segment(0, 0, 0, 0)
line.__class__ = ModifiedSegment
line.setVisible(0)
setupCommonStyle(line, marker)
label = make.info_label("TR", [MzCursorInfo(marker, line)], title=None)
label.labelparam.label = ""
self.marker = marker
self.label = label
self.line = line
def setHalfWindowWidth(self, w2):
self.widget.plot.set_half_window_width(w2)
def setCentralMz(self, mz):
self.widget.plot.set_central_mz(mz)
def handle_c_pressed(self, p):
if self.c_callback:
self.c_callback(p)
def plot(self, data, configs=None, titles=None):
""" do not forget to call replot() after calling this function ! """
self.widget.plot.del_all_items()
self.widget.plot.add_item(self.marker)
if titles is not None:
self.widget.plot.add_item(make.legend("TL"))
self.widget.plot.add_item(self.label)
all_peaks = []
self.widget.plot.data = []
self.widget.plot.curves = []
for i, (pm, rtmin, rtmax, mzmin, mzmax, npeaks) in enumerate(data):
if rtmin is None and rtmax is None:
rtmin, rtmax = pm.rtRange()
elif rtmin is None:
rtmin, __ = pm.rtRange()
elif rtmax is None:
__, rtmax = pm.rtRange()
if mzmin is None and mzmax is None:
mzmin, mzmax = pm.mzRange()
elif mzmin is None:
mzmin, __ = pm.mzRange()
elif mzmax is None:
__, mzmax = pm.mzRange()
if npeaks is None:
npeaks = 3000
peaks = sample_peaks(pm, rtmin, rtmax, mzmin, mzmax, npeaks)
all_peaks.append(peaks)
config = configs[i] if configs is not None else None
if config is None:
config = dict(color=getColor(i))
if titles is not None:
title = titles[i]
else:
title = u""
curve = make.curve([], [], title=title, curvestyle="Sticks", **config)
curve.set_data(peaks[:, 0], peaks[:, 1])
#.........这里部分代码省略.........
示例13: RealtimeDemo
# 需要导入模块: from guiqwt.plot import PlotManager [as 别名]
# 或者: from guiqwt.plot.PlotManager import add_plot [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()
示例14: Ui_Form
# 需要导入模块: from guiqwt.plot import PlotManager [as 别名]
# 或者: from guiqwt.plot.PlotManager import add_plot [as 别名]
class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName(_fromUtf8("Form"))
Form.resize(750, 453)
self.Form = Form
self.pushButton = QtGui.QPushButton(Form)
self.pushButton.setGeometry(QtCore.QRect(30, 0, 75, 23))
self.pushButton.setObjectName(_fromUtf8("pushButton"))
'''self.checkBox = QtGui.QCheckBox(Form)
self.checkBox.setGeometry(QtCore.QRect(20, 70, 70, 17))
self.checkBox.setObjectName(_fromUtf8("checkBox"))
self.checkBox_2 = QtGui.QCheckBox(Form)
self.checkBox_2.setGeometry(QtCore.QRect(100, 70, 70, 17))
self.checkBox_2.setObjectName(_fromUtf8("checkBox_2"))
self.checkBox_3 = QtGui.QCheckBox(Form)
self.checkBox_3.setGeometry(QtCore.QRect(180, 70, 70, 17))
self.checkBox_3.setObjectName(_fromUtf8("checkBox_3"))'''
self.widget = QtGui.QWidget(Form)
self.widget.setGeometry(QtCore.QRect(10, 110, 581, 251))
self.widget.setObjectName(_fromUtf8("widget"))
self.startD = QtGui.QLineEdit(Form)
self.startD.setGeometry(QtCore.QRect(120, 0, 81, 20))
self.startD.setObjectName(_fromUtf8("startD"))
self.endD = QtGui.QLineEdit(Form)
self.endD.setGeometry(QtCore.QRect(240, 0, 71, 20))
self.endD.setObjectName(_fromUtf8("endD"))
self.label = QtGui.QLabel(Form)
self.label.setGeometry(QtCore.QRect(290, 20, 46, 13))
self.label.setObjectName(_fromUtf8("label"))
self.label_2 = QtGui.QLabel(Form)
self.label_2.setGeometry(QtCore.QRect(170, 20, 46, 13))
self.label_2.setObjectName(_fromUtf8("label_2"))
self.Hint = QtGui.QLabel(Form)
self.Hint.setGeometry(QtCore.QRect(330, 10, 281, 16))
self.Hint.setObjectName(_fromUtf8("Hint"))
self.pushButton_2 = QtGui.QPushButton(Form)
self.pushButton_2.setGeometry(QtCore.QRect(30, 30, 75, 23))
self.pushButton_2.setObjectName(_fromUtf8("pushButton_2"))
self.pushButton.clicked.connect(self.loadDialog)
self.pushButton_2.clicked.connect(self.saveDialog)
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
def retranslateUi(self, Form):
Form.setWindowTitle(_translate("Form", "Form", None))
self.pushButton.setText(_translate("Form", "Load Data", None))
self.label.setText(_translate("Form", "End", None))
self.label_2.setText(_translate("Form", "Begin", None))
self.Hint.setText(_translate("Form", "Enter before loading. To load whole dataset, leave blank", None))
self.pushButton_2.setText(_translate("Form", "Save", None))
def loadDialog(self):
filename = QtGui.QFileDialog.getOpenFileName(self.Form, 'Open File', '.')
fname = open(filename)
data = fname.read()
#self.le.setText(filename)
do = pandas.read_csv(str(filename), delimiter=",")
#data = pd.read_csv('C:/Users/se00075/PycharmProjects/Test2/src' + '/' + 'data.csv')
if (self.startD.text().isEmpty()) & (self.endD.text().isEmpty()):
d=do
else:
do['time_stamp'] = do['time_stamp'].astype('datetime64[ns]')
st = int(self.startD.text())
en = int(self.endD.text())
select = (do['time_stamp'] >= do.time_stamp[0]+datetime.timedelta(days=st-1)) & (do['time_stamp'] < do.time_stamp[0]+datetime.timedelta(days=en))
d = do[select]
#d = pandas.read_csv(str(filename), delimiter=",")
#print d
##Lets add clean missing data here
space = 0
self.checkboxes = []
for i in d.columns:
c = QtGui.QCheckBox(self.Form)
#print space
c.setGeometry(QtCore.QRect(10 + space, 50, 70, 17))
c.setText(_fromUtf8(i))
c.show()
c.clicked.connect(self.selected)
self.checkboxes.append(c)
space += 68
self.original_data = d
#self.original_data=(self.original_data-self.original_data.mean()) / self.original_data.std()
self.dialog = CurveDialog(edit=False, toolbar=False, parent=self.widget)
self.plot = self.dialog.get_plot()
self.plot.set_antialiasing(True)
self.plot.setAxisTitle(Qwt5.Qwt.QwtPlot.xBottom, 'Time')
self.plot.setAxisTitle(Qwt5.Qwt.QwtPlot.yLeft, 'Value')
self.manager = PlotManager(self)
self.manager.add_plot(self.plot)
legend = make.legend('TL')
self.plot.add_item(legend)
ly = QtGui.QVBoxLayout()
ly.addWidget(self.plot)
self.widget.setLayout(ly)
self.widget.show()
#.........这里部分代码省略.........
示例15: plotWindow
# 需要导入模块: from guiqwt.plot import PlotManager [as 别名]
# 或者: from guiqwt.plot.PlotManager import add_plot [as 别名]
#.........这里部分代码省略.........
# end addImagePlot
def addImageWidget(self, images, *args, **kwargs):
widget = ImageWidget(self, *args, **kwargs)
plot = widget.get_plot()
if (images.__class__ is not list):
plot.add_item(images)
else:
for image in images:
plot.add_item(image)
# end for
# end if
self.centralWidget().layout().addWidget(widget)
self.__l_layoutChilds.append(widget)
return widget
# end addImageWidget
def getManager(self):
return self.__p_manager
# end getManager
def __addPlot(self, dataList, plotClass, *args, **kwargs):
"""
pos[0]: row
pos[1]: column
pos[2]: rowspan
pos[3]: columnspan
"""
pos = []
if ('position' in kwargs):
pos = kwargs.pop('position')
# end if
if ('pos' in kwargs):
pos = kwargs.pop('pos')
# end if
plot = plotClass(self, *args, **kwargs)
if (dataList.__class__ is not list):
plot.add_item(dataList)
else:
for data in dataList:
plot.add_item(data)
# end for
# end if
self.__registerPlot(plot, pos)
return plot
# end __addPlot
def __registerPlot(self, plot, pos):
# check for position
if (pos != []):
if (len(pos) == 2):
pos.append(1) # rowspan
pos.append(1) # columnspan
# end if
self.centralWidget().layout().addWidget(plot, pos[0], pos[1], pos[2], pos[3])
else:
self.centralWidget().layout().addWidget(plot)
# end if
self.__l_layoutChilds.append(plot)
self.__p_manager.add_plot(plot)
# end __registerPLot
def show(self, *args, **kwargs):
if (self.__v_wasInitialized):
self.__p_manager.register_all_curve_tools()
self.__v_wasInitialized = False
# end if
QMainWindow.show(self, *args, **kwargs)
# end show
def showEvent(self, event):
# emit signal
self.emit(SIGNAL("onShow()"))
# execute not overloaded showEvent
QMainWindow.showEvent(self, event)
# end showEvent
def closeEvent(self, event):
# emit signal
self.emit(SIGNAL("onClose()"))
# execute not overloaded closeEvent
QMainWindow.closeEvent(self, event)
# end closeEvent
def __onAutoScale(self):
plot = self.__p_manager.get_active_plot()
plot.do_autoscale(True)