本文整理汇总了Python中matplotlib.backends.backend_qt5agg.NavigationToolbar2QT.home方法的典型用法代码示例。如果您正苦于以下问题:Python NavigationToolbar2QT.home方法的具体用法?Python NavigationToolbar2QT.home怎么用?Python NavigationToolbar2QT.home使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.backends.backend_qt5agg.NavigationToolbar2QT
的用法示例。
在下文中一共展示了NavigationToolbar2QT.home方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: matplotlibWidget
# 需要导入模块: from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT [as 别名]
# 或者: from matplotlib.backends.backend_qt5agg.NavigationToolbar2QT import home [as 别名]
class matplotlibWidget(QWidget):
def __init__(self, parent = None):
QWidget.__init__(self, parent)
self.canvas = MplCanvas()
self.gl = QGridLayout()
alignment = Qt.Alignment()
self.gl.addWidget(self.canvas,0,0,-1,-1,alignment)
self.toolbar = NavigationToolbar(self.canvas, self)
self.toolbar.hide()
# Just some button
self.button1 = QPushButton('Zoom')
self.button1.clicked.connect(self.zoom)
self.button2 = QPushButton('Pan')
self.button2.clicked.connect(self.pan)
self.button3 = QPushButton('Home')
self.button3.clicked.connect(self.home)
self.gl.addWidget(self.toolbar,1,0,alignment)
self.gl.addWidget(self.button1,1,1,alignment)
self.gl.addWidget(self.button2,1,2,alignment)
self.gl.addWidget(self.button3,1,3,alignment)
self.setLayout(self.gl)
def home(self):
self.toolbar.home()
def zoom(self):
self.toolbar.zoom()
def pan(self):
self.toolbar.pan()
示例2: PulsedNMR
# 需要导入模块: from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT [as 别名]
# 或者: from matplotlib.backends.backend_qt5agg.NavigationToolbar2QT import home [as 别名]
class PulsedNMR(QMainWindow, Ui_PulsedNMR):
rates = {0:25.0e3, 1:50.0e3, 2:250.0e3, 3:500.0e3, 4:2500.0e3}
def __init__(self):
super(PulsedNMR, self).__init__()
self.setupUi(self)
self.rateValue.addItems(['25', '50', '250', '500', '2500'])
# IP address validator
rx = QRegExp('^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]).){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$')
self.addrValue.setValidator(QRegExpValidator(rx, self.addrValue))
# state variable
self.idle = True
# number of samples to show on the plot
self.size = 50000
# buffer and offset for the incoming samples
self.buffer = bytearray(8 * self.size)
self.offset = 0
# create figure
figure = Figure()
figure.set_facecolor('none')
self.axes = figure.add_subplot(111)
self.canvas = FigureCanvas(figure)
self.plotLayout.addWidget(self.canvas)
# create navigation toolbar
self.toolbar = NavigationToolbar(self.canvas, self.plotWidget, False)
# remove subplots action
actions = self.toolbar.actions()
self.toolbar.removeAction(actions[7])
self.plotLayout.addWidget(self.toolbar)
# create TCP socket
self.socket = QTcpSocket(self)
self.socket.connected.connect(self.connected)
self.socket.readyRead.connect(self.read_data)
self.socket.error.connect(self.display_error)
# connect signals from buttons and boxes
self.startButton.clicked.connect(self.start)
self.freqValue.valueChanged.connect(self.set_freq)
self.awidthValue.valueChanged.connect(self.set_awidth)
self.deltaValue.valueChanged.connect(self.set_delta)
self.rateValue.currentIndexChanged.connect(self.set_rate)
# set rate
self.rateValue.setCurrentIndex(2)
# create timer for the repetitions
self.timer = QTimer(self)
self.timer.timeout.connect(self.fire)
def start(self):
if self.idle:
self.startButton.setEnabled(False)
self.socket.connectToHost(self.addrValue.text(), 1001)
else:
self.idle = True
self.timer.stop()
self.socket.close()
self.offset = 0
self.startButton.setText('Start')
self.startButton.setEnabled(True)
def connected(self):
self.idle = False
self.set_freq(self.freqValue.value())
self.set_rate(self.rateValue.currentIndex())
self.set_awidth(self.awidthValue.value())
self.fire()
self.timer.start(self.deltaValue.value())
self.startButton.setText('Stop')
self.startButton.setEnabled(True)
def read_data(self):
size = self.socket.bytesAvailable()
if self.offset + size < 8 * self.size:
self.buffer[self.offset:self.offset + size] = self.socket.read(size)
self.offset += size
else:
self.buffer[self.offset:8 * self.size] = self.socket.read(8 * self.size - self.offset)
self.offset = 0
# plot the signal envelope
data = np.frombuffer(self.buffer, np.complex64)
self.curve.set_ydata(np.abs(data))
self.canvas.draw()
def display_error(self, socketError):
if socketError == QAbstractSocket.RemoteHostClosedError:
pass
else:
QMessageBox.information(self, 'PulsedNMR', 'Error: %s.' % self.socket.errorString())
self.startButton.setText('Start')
self.startButton.setEnabled(True)
def set_freq(self, value):
if self.idle: return
self.socket.write(struct.pack('<I', 0<<28 | int(1.0e6 * value)))
def set_rate(self, index):
# time axis
rate = float(PulsedNMR.rates[index])
time = np.linspace(0.0, (self.size - 1) * 1000.0 / rate, self.size)
# reset toolbar
self.toolbar.home()
self.toolbar._views.clear()
self.toolbar._positions.clear()
#.........这里部分代码省略.........
示例3: home
# 需要导入模块: from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT [as 别名]
# 或者: from matplotlib.backends.backend_qt5agg.NavigationToolbar2QT import home [as 别名]
def home(self, *args):
# call super's home() method
NavigationToolbar2QT.home(self, args)
# send a signal to parent class for further operation
self.home_button_pressed.emit()
示例4: Ui_MainWindow
# 需要导入模块: from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT [as 别名]
# 或者: from matplotlib.backends.backend_qt5agg.NavigationToolbar2QT import home [as 别名]
#.........这里部分代码省略.........
try:
exec("self.df = self.orig_df[" + self.filterStr.replace("df","self.orig_df") + "]" )
self.lastFilterStr = self.filterStr
except Exception as e:
msg = QMessageBox()
msg.setIcon(QMessageBox.Warning)
msg.setText("Filtering failed")
msg.setWindowTitle("Error")
msg.setDetailedText( str(e) )
msg.setStandardButtons(QMessageBox.Ok)
msg.exec_()
pass
pass
pass
else:
self.df = self.orig_df
return True
def updateTable(self):
if self.data() is None: return
header = self.columns
tm = MyTableModel.MyTableModel(self.df.values, header, self)
self.tableView.setModel(tm)
vh = self.tableView.verticalHeader()
vh.setVisible(False)
hh = self.tableView.horizontalHeader()
hh.setStretchLastSection(True)
self.tableView.setSortingEnabled(True)
#self.tableView.sortByColumn(0);
tm.sort( 0, Qt.AscendingOrder )
def plotZoom(self): self.toolbar.zoom()
def plotPan(self): self.toolbar.pan()
def plotHome(self): self.toolbar.home()
def on_treeView_doubleClicked(self, index, fileName = '' ):
if fileName == '':
fileName = str(index.model().filePath(index))
if self.fileName == fileName: return
if self.hdfStore is not None:
self.hdfStore.close()
if fileName.endswith( ".csv" ):
self.hdfStore = None
self.fileName = fileName
self.isCsv = True
self.isH5 = False
self.orig_df = pd.read_csv( fileName )
self.setupCsv()
elif fileName.endswith(".h5"):
self.fileName = fileName
self.isCsv = False
self.isH5 = True
self.hdfStore = pd.HDFStore( fileName, 'r' )
self.setupH5()
def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(_translate("MainWindow", "PandaViz", None))
import os.path as osp
path = osp.join(osp.dirname(sys.modules[__name__].__file__), 'PandaViz.jpg')
MainWindow.setWindowIcon(QIcon(path))
self.btnZoom.setText(_translate("MainWindow", "Zoom", None))
self.btnPlot.setText(_translate("MainWindow", "Draw", None))
self.btnPan.setText(_translate("MainWindow", "Pan", None))