本文整理汇总了Python中matplotlib.backends.backend_qt4agg.NavigationToolbar2QTAgg.zoom方法的典型用法代码示例。如果您正苦于以下问题:Python NavigationToolbar2QTAgg.zoom方法的具体用法?Python NavigationToolbar2QTAgg.zoom怎么用?Python NavigationToolbar2QTAgg.zoom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.backends.backend_qt4agg.NavigationToolbar2QTAgg
的用法示例。
在下文中一共展示了NavigationToolbar2QTAgg.zoom方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Window
# 需要导入模块: from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.NavigationToolbar2QTAgg import zoom [as 别名]
class Window(QtGui.QDialog):
def __init__(self, parent=None):
super(Window, self).__init__(parent)
self.figure = plt.figure()
self.canvas = FigureCanvas(self.figure)
self.toolbar = NavigationToolbar(self.canvas, self)
# self.toolbar.hide()
# Just some button
self.button = QtGui.QPushButton('Plot')
self.button.clicked.connect(self.plot)
self.button1 = QtGui.QPushButton('Zoom')
self.button1.clicked.connect(self.zoom)
self.button2 = QtGui.QPushButton('Pan')
self.button2.clicked.connect(self.pan)
self.button3 = QtGui.QPushButton('Home')
self.button3.clicked.connect(self.home)
# set the layout
layout = QtGui.QVBoxLayout()
layout.addWidget(self.toolbar)
layout.addWidget(self.canvas)
layout.addWidget(self.button)
layout.addWidget(self.button1)
layout.addWidget(self.button2)
layout.addWidget(self.button3)
self.setLayout(layout)
def home(self):
self.toolbar.home()
def zoom(self):
self.toolbar.zoom()
def pan(self):
self.toolbar.pan()
def plot(self):
''' plot some random stuff '''
data = [random.random() for i in range(25)]
ax = self.figure.add_subplot(211)
ax.hold(False)
ax.plot(data, '*-')
bx = self.figure.add_subplot(212)
bx.hold(False)
bx.plot(data, '*-')
self.canvas.draw()
示例2: MPlotWidget
# 需要导入模块: from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.NavigationToolbar2QTAgg import zoom [as 别名]
class MPlotWidget(QtGui.QWidget):
def __init__(self, parent=None):
super(MPlotWidget, self).__init__(parent)
self.figure = plt.figure()
self.canvas = FigureCanvas(self.figure)
self.toolbar = NavigationToolbar(self.canvas, self)
self.toolbar.hide()
self.plotbutton = QtGui.QPushButton('Plot')
self.zoombutton = QtGui.QPushButton('Zoom')
self.zoombutton.clicked.connect(self.zoom)
self.panbutton = QtGui.QPushButton('Pan')
self.panbutton.clicked.connect(self.pan)
self.homebutton = QtGui.QPushButton('Home')
self.homebutton.clicked.connect(self.home)
self.savebutton = QtGui.QPushButton('Save')
self.savebutton.clicked.connect(self.save)
layout = QtGui.QVBoxLayout()
layout.addWidget(self.toolbar)
layout.addWidget(self.canvas)
buttonbox = QtGui.QHBoxLayout()
buttonbox.addWidget(self.plotbutton)
buttonbox.addWidget(self.zoombutton)
buttonbox.addWidget(self.panbutton)
buttonbox.addWidget(self.homebutton)
buttonbox.addWidget(self.savebutton)
layout.addLayout(buttonbox)
self.setLayout(layout)
self.ax = self.figure.add_subplot(111)
self.ax.hold(False)
def home(self):
self.toolbar.home()
def zoom(self):
self.toolbar.zoom()
def pan(self):
self.toolbar.pan()
def save(self):
self.figure.savefig('1.png')
"""
示例3: zoom
# 需要导入模块: from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.NavigationToolbar2QTAgg import zoom [as 别名]
def zoom(self, *args):
"""
Turn on/off zoom (zoom button)
:param args:
:return:
"""
NavigationToolbar2.zoom(self, args)
if self._navigationMode == MyNavigationToolbar.NAVIGATION_MODE_ZOOM:
# out of zoom mode
self._navigationMode = MyNavigationToolbar.NAVIGATION_MODE_NONE
else:
# into zoom mode
self._navigationMode = MyNavigationToolbar.NAVIGATION_MODE_ZOOM
return
示例4: zoom
# 需要导入模块: from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.NavigationToolbar2QTAgg import zoom [as 别名]
def zoom( self, *args ):
self.resetActionsState( self.zoomAction )
NavigationToolbar2QTAgg.zoom( self, *args )
示例5: calibrlogger
# 需要导入模块: from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.NavigationToolbar2QTAgg import zoom [as 别名]
#.........这里部分代码省略.........
self.plot_recarray(self.axes, self.level_masl_ts, obsid + unicode(' logger', 'utf-8'), logger_line_style, 10)
#Plot the original head_cm
if self.plot_logger_head.isChecked():
self.plot_recarray(self.axes, self.head_ts, obsid + unicode(' original logger head', 'utf-8'), logger_line_style, 10)
""" Finish plot """
self.axes.grid(True)
self.axes.yaxis.set_major_formatter(tick.ScalarFormatter(useOffset=False, useMathText=False))
self.calibrplotfigure.autofmt_xdate()
self.axes.set_ylabel(unicode('Level (masl)', 'utf-8')) #This is the method that accepts even national characters ('åäö') in matplotlib axes labels
self.axes.set_title(unicode('Calibration plot for ', 'utf-8') + str(obsid)) #This is the method that accepts even national characters ('åäö') in matplotlib axes labels
for label in self.axes.xaxis.get_ticklabels():
label.set_fontsize(10)
for label in self.axes.yaxis.get_ticklabels():
label.set_fontsize(10)
#plt.show()
self.canvas.draw()
plt.close(self.calibrplotfigure)#this closes reference to self.calibrplotfigure
PyQt4.QtGui.QApplication.restoreOverrideCursor()
self.calib_help.setText("")
def plot_recarray(self, axes, a_recarray, lable, line_style, picker=10):
""" Plots a recarray to the supplied axes object """
# Get help from function datestr2num to get date and time into float
myTimestring = [a_recarray.date_time[idx] for idx in xrange(len(a_recarray))]
numtime=datestr2num(myTimestring) #conv list of strings to numpy.ndarray of floats
axes.plot_date(numtime, a_recarray.values, line_style, label=lable, picker=picker)
def set_from_date_from_x(self):
""" Used to set the self.FromDateTime by clicking on a line node in the plot self.canvas """
self.reset_plot_selects_and_calib_help()
self.calib_help.setText("Select a node to use as \"from\"")
self.deactivate_pan_zoom()
self.canvas.setFocusPolicy(Qt.ClickFocus)
self.canvas.setFocus()
self.cid.append(self.canvas.mpl_connect('pick_event', lambda event: self.set_date_from_x_onclick(event, self.FromDateTime)))
def set_to_date_from_x(self):
""" Used to set the self.ToDateTime by clicking on a line node in the plot self.canvas """
self.reset_plot_selects_and_calib_help()
self.calib_help.setText("Select a node to use as \"to\"")
self.deactivate_pan_zoom()
self.canvas.setFocusPolicy(Qt.ClickFocus)
self.canvas.setFocus()
self.cid.append(self.canvas.mpl_connect('pick_event', lambda event: self.set_date_from_x_onclick(event, self.ToDateTime)))
def set_date_from_x_onclick(self, event, date_holder):
""" Sets the date_holder to a date from a line node closest to the pick event
date_holder: a QDateTimeEdit object.
"""
found_date = utils.find_nearest_date_from_event(event)
date_holder.setDateTime(found_date)
self.reset_plot_selects_and_calib_help()
def reset_plot_selects_and_calib_help(self):
""" Reset self.cid and self.calib_help """
self.reset_cid()
self.log_pos = None
self.y_pos = None
self.calib_help.setText("")
def reset_cid(self):
""" Resets self.cid to an empty list and disconnects unused events """
for x in self.cid:
示例6: Window
# 需要导入模块: from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.NavigationToolbar2QTAgg import zoom [as 别名]
class Window(QtGui.QDialog):
def __init__(self, parent=None):
super(Window, self).__init__(parent)
self.figure = plt.figure()
self.canvas = FigureCanvas(self.figure)
self.canvas.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Expanding)
self.toolbar = NavigationToolbar(self.canvas, self)
self.toolbar.hide()
# Timestream info
self.timestreamLabel = QtGui.QLabel('Time-stream root path:')
self.timestreamText = QtGui.QLineEdit('')
self.timestreamText.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed)
self.timestreamDateLabel = QtGui.QLabel('Start date (yyyy_mm_dd_hh_mm_ss):')
self.timestreamDateText = QtGui.QLineEdit('')
self.timestreamDateText.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed)
self.timestreamTimeLabel = QtGui.QLabel('Time interval (seconds):')
self.timestreamTimeText = QtGui.QLineEdit('')
self.timestreamTimeText.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed)
self.initStreamTimeButton = QtGui.QPushButton('&Initialise timestream by time')
self.initStreamTimeButton.clicked.connect(self.initialiseTimestreamByTime)
self.initStreamFileButton = QtGui.QPushButton('&Initialise timestream by files')
self.initStreamFileButton.clicked.connect(self.initialiseTimestreamByFiles)
# Image loading and processing
self.loadImageButton = QtGui.QPushButton('&Load (next) image')
self.loadImageButton.clicked.connect(self.loadImage)
self.rotateImageButton = QtGui.QPushButton('&Rotate 90-deg')
self.rotateImageButton.clicked.connect(self.rotateImage90Degrees)
self.slider = QtGui.QSlider(QtCore.Qt.Horizontal)
self.slider.setFocusPolicy(QtCore.Qt.StrongFocus)
self.slider.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed)
self.slider.setTickPosition(QtGui.QSlider.TicksBothSides)
self.slider.setMinimum(-16)
self.slider.setMaximum(16)
self.slider.setValue(0)
self.slider.setTickInterval(4)
self.slider.setSingleStep(1)
self.slider.valueChanged.connect(self.rotateSmallAngle)
self.applySmallRotationButton = QtGui.QPushButton('&Apply')
self.applySmallRotationButton.clicked.connect(self.applySmallRotation)
self.loadCamCalibButton = QtGui.QPushButton('Load &cam. param.')
self.loadCamCalibButton.clicked.connect(self.loadCamCalib)
self.colorcardRadioButton = QtGui.QRadioButton('Select color car&d')
self.colorcardRadioButton.setChecked(False)
self.colorcardRadioButton.clicked.connect(self.selectWhat)
self.trayRadioButton = QtGui.QRadioButton('Select &tray')
self.trayRadioButton.setChecked(False)
self.trayRadioButton.clicked.connect(self.selectWhat)
self.trayRoundCheckBox = QtGui.QCheckBox('Round')
self.trayRoundCheckBox.setChecked(True)
self.potRadioButton = QtGui.QRadioButton('Select &pot')
self.potRadioButton.setChecked(False)
self.potRadioButton.clicked.connect(self.selectWhat)
self.zoomButton = QtGui.QPushButton('&Zoom')
self.zoomButton.setCheckable(True)
self.zoomButton.clicked.connect(self.zoom)
self.panButton = QtGui.QPushButton('&Pan')
self.panButton.setCheckable(True)
self.panButton.clicked.connect(self.pan)
self.homeButton = QtGui.QPushButton('&Home')
self.homeButton.clicked.connect(self.home)
self.correctColorButton = QtGui.QPushButton('Correct colo&r')
self.correctColorButton.clicked.connect(self.correctColor)
self.save2PipelineButton = QtGui.QPushButton('&Save as pipeline settings')
self.save2PipelineButton.clicked.connect(self.savePipelineSettings)
self.testPipelineButton = QtGui.QPushButton('Test &pipeline processing')
self.testPipelineButton.clicked.connect(self.testPipeline)
self.status = QtGui.QTextEdit('')
self.status.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Expanding)
self.mousePosition = QtGui.QLabel('')
# set the layout
layout = QtGui.QHBoxLayout()
rightWidget = QtGui.QWidget()
buttonlayout = QtGui.QVBoxLayout(rightWidget)
buttonlayout.addWidget(self.timestreamLabel)
buttonlayout.addWidget(self.timestreamText)
buttonlayout.addWidget(self.timestreamDateLabel)
#.........这里部分代码省略.........
示例7: zoom
# 需要导入模块: from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.NavigationToolbar2QTAgg import zoom [as 别名]
def zoom(self, *args) :
print 'Zoom is clicked'
NavigationToolbar.zoom(self)
fig = self.canvas.figure
if fig.ntbZoomIsOn : fig.ntbZoomIsOn = False
else : fig.ntbZoomIsOn = True
示例8: zoom
# 需要导入模块: from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.NavigationToolbar2QTAgg import zoom [as 别名]
def zoom(self, *args) :
print 'Zoom is clicked'
NavigationToolbar.zoom(self)
示例9: Window
# 需要导入模块: from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.NavigationToolbar2QTAgg import zoom [as 别名]
class Window(QtGui.QDialog):
def __init__(self, parent=None):
super(Window, self).__init__(parent)
self.figure = plt.figure()
self.canvas = FigureCanvas(self.figure)
self.canvas.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Expanding)
self.toolbar = NavigationToolbar(self.canvas, self)
self.toolbar.hide()
# Just some button
self.colorcardRadioButton = QtGui.QRadioButton('Select color car&d')
self.colorcardRadioButton.setChecked(False)
self.colorcardRadioButton.clicked.connect(self.selectWhat)
self.trayRadioButton = QtGui.QRadioButton('Select &tray')
self.trayRadioButton.setChecked(False)
self.trayRadioButton.clicked.connect(self.selectWhat)
self.potRadioButton = QtGui.QRadioButton('Select &pot')
self.potRadioButton.setChecked(False)
self.potRadioButton.clicked.connect(self.selectWhat)
self.loadImageButton = QtGui.QPushButton('&Load image')
self.loadImageButton.clicked.connect(self.loadImage)
self.rotateImageButton = QtGui.QPushButton('&Rotate 90-deg')
self.rotateImageButton.clicked.connect(self.rotateImage90Degrees)
self.loadCamCalibButton = QtGui.QPushButton('Load &cam. param.')
self.loadCamCalibButton.clicked.connect(self.loadCamCalib)
self.saveGeometriesButton = QtGui.QPushButton('&Save selected geometries')
self.saveGeometriesButton.clicked.connect(self.saveSelectedGeometries)
self.saveTraysButton = QtGui.QPushButton('&Save selected tray images')
self.saveTraysButton.clicked.connect(self.saveSelectedTrayImages)
self.saveColorcadButton = QtGui.QPushButton('&Save sel. col. card images')
self.saveColorcadButton.clicked.connect(self.saveSelectedColorcardImages)
self.save2PipelineButton = QtGui.QPushButton('&Save as pipeline settings')
self.save2PipelineButton.clicked.connect(self.savePipelineSettings)
self.zoomButton = QtGui.QPushButton('&Zoom')
self.zoomButton.setCheckable(True)
self.zoomButton.clicked.connect(self.zoom)
self.panButton = QtGui.QPushButton('&Pan')
self.panButton.setCheckable(True)
self.panButton.clicked.connect(self.pan)
self.homeButton = QtGui.QPushButton('&Home')
self.homeButton.clicked.connect(self.home)
self.status = QtGui.QTextEdit('')
self.status.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Expanding)
self.mousePosition = QtGui.QLabel('')
# set the layout
layout = QtGui.QHBoxLayout()
rightWidget = QtGui.QWidget()
buttonlayout = QtGui.QVBoxLayout(rightWidget)
buttonlayout.addWidget(self.loadImageButton)
buttonlayout.addWidget(self.rotateImageButton)
buttonlayout.addWidget(self.loadCamCalibButton)
buttonlayout.addWidget(self.colorcardRadioButton)
buttonlayout.addWidget(self.trayRadioButton)
buttonlayout.addWidget(self.potRadioButton)
buttonlayout.addWidget(self.zoomButton)
buttonlayout.addWidget(self.panButton)
buttonlayout.addWidget(self.homeButton)
buttonlayout.addWidget(self.saveGeometriesButton)
buttonlayout.addWidget(self.saveColorcadButton)
buttonlayout.addWidget(self.saveTraysButton)
buttonlayout.addWidget(self.save2PipelineButton)
buttonlayout.addWidget(self.status)
buttonlayout.addWidget(self.mousePosition)
rightWidget.setMaximumWidth(200)
leftLayout = QtGui.QVBoxLayout()
leftLayout.addWidget(self.toolbar)
leftLayout.addWidget(self.canvas)
layout.addWidget(rightWidget)
layout.addLayout(leftLayout)
self.setLayout(layout)
self.group = QtGui.QButtonGroup()
self.group.addButton(self.colorcardRadioButton)
self.group.addButton(self.trayRadioButton)
self.group.addButton(self.potRadioButton)
self.panMode = False
self.zoomMode = False
self.ax = None
self.plotRect = None
self.plotImg = None
self.image = None
#.........这里部分代码省略.........