本文整理汇总了Python中pyqtgraph.PlotWidget.setLimits方法的典型用法代码示例。如果您正苦于以下问题:Python PlotWidget.setLimits方法的具体用法?Python PlotWidget.setLimits怎么用?Python PlotWidget.setLimits使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyqtgraph.PlotWidget
的用法示例。
在下文中一共展示了PlotWidget.setLimits方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Tiare
# 需要导入模块: from pyqtgraph import PlotWidget [as 别名]
# 或者: from pyqtgraph.PlotWidget import setLimits [as 别名]
class Tiare(QtGui.QMainWindow):
def __init__(self, *args):
QtGui.QMainWindow.__init__(self, *args)
self.statusBar().showMessage('Pret')
self.th = 0
self.widget = QtGui.QWidget(self)
exitAction = QtGui.QAction(QtGui.QIcon('exit.png'), '&Quitter', self)
exitAction.setShortcut('Ctrl+Q')
exitAction.setStatusTip("Ferme l'application")
exitAction.triggered.connect(self.close)
openAction = QtGui.QAction(QtGui.QIcon('open.png'), '&Charger', self)
openAction.setShortcut('Ctrl+L')
openAction.setStatusTip("Charge un fichier wav")
openAction.triggered.connect(self.load)
self.saveAction = QtGui.QAction(QtGui.QIcon('save.png'), '&Exporter', self)
self.saveAction.setShortcut('Ctrl+S')
self.saveAction.setStatusTip("Exporter en CSV")
self.saveAction.triggered.connect(self.export)
self.saveAction.setEnabled(False)
menubar = self.menuBar()
fileMenu = menubar.addMenu('&Fichier')
fileMenu.addAction(openAction)
fileMenu.addAction(self.saveAction)
fileMenu.addAction(exitAction)
self.th_slider = QtGui.QSlider(QtCore.Qt.Horizontal, self)
self.th_slider.setValue(self.th)
self.th_slider.valueChanged[int].connect(self.change_threshold)
self.min_len = QtGui.QSlider(QtCore.Qt.Horizontal, self)
self.min_len.setValue(10)
self.min_len.setMinimum(1)
self.min_len.setMaximum(100)
self.min_len.valueChanged[int].connect(self.change_min_len)
self.min_len_sil = QtGui.QSlider(QtCore.Qt.Horizontal, self)
self.min_len_sil.setValue(10)
self.min_len_sil.setMinimum(1)
self.min_len_sil.setMaximum(100)
self.min_len_sil.valueChanged[int].connect(self.change_min_len)
# Make sizer and embed stuff
self.sizer = QtGui.QVBoxLayout(self.widget)
self.fig_signal = PlotWidget(self.widget, background="w")
self.fig_signal.setLimits(xMin=0, yMin=-1, yMax=1, minXRange=1, maxXRange=30, minYRange=2, maxYRange=2)
self.fig_energy = PlotWidget(self.widget, background="w")
self.fig_energy.setXLink(self.fig_signal)
self.fig_segments = PlotWidget(self.widget, background="w")
self.fig_segments.setXLink(self.fig_signal)
self.fig_segments.hideAxis('bottom')
self.fig_segments.hideAxis('left')
self.fig_segments.setLimits(yMin=-1, yMax=1, minYRange=2, maxYRange=2)
self.sizer.addWidget(self.fig_signal, 5)
self.sizer.addWidget(self.fig_energy, 5)
self.sizer.addWidget(self.fig_segments, 3)
self.sizer.addWidget(QtGui.QLabel('Seuil de segmentation'), 0)
self.sizer.addWidget(self.th_slider, 0)
self.min_seg_label = QtGui.QLabel('Longeur minimal de segment (%.3f s)' % (float(self.min_len.value())/100))
self.sizer.addWidget(self.min_seg_label, 0)
self.sizer.addWidget(self.min_len, 0)
self.min_sil_label = QtGui.QLabel('Longeur minimal de silence (%.3f s)' % (float(self.min_len_sil.value())/100))
self.sizer.addWidget(self.min_sil_label, 0)
self.sizer.addWidget(self.min_len_sil, 0)
# Apply sizers
self.setCentralWidget(self.widget)
# Finish
self.resize(560, 420)
self.setWindowTitle('Tiare')
self.energy_tl, self.energy = [], []
self.thline = None
self.seg_up = None
self.seg_down = None
self.fig_energy_plot = None
self.segments = []
self.samples = []
self.sr = 0
self.filepath = None
self.widget.hide()
self.show()
def change_threshold(self, value):
value = float(value)/100
if self.thline is not None :
self.thline.setData([self.energy_tl[0], self.energy_tl[-1]], [value]*2)
self.segments = map(lambda (x, y): (self.energy_tl[x],self.energy_tl[y]),
cut(self.energy, value, self.min_len.value(), self.min_len_sil.value()))
x = [v for start, stop in self.segments for v in [start, start, stop, stop]]
y = [v for _ in self.segments for v in [-0.85, 0.85, 0.85, -0.85]]
self.seg_up.setData(x, y)
self.seg_down.setData([self.energy_tl[0], self.energy_tl[-1]], [-0.85, -0.85])
def change_min_len(self, value=0):
self.min_seg_label.setText("Longeur minimale d'un segment (%.3f s)" % (float(self.min_len.value())/100))
#.........这里部分代码省略.........