本文整理汇总了Python中matplotlib.backends.backend_qt5agg.NavigationToolbar2QT类的典型用法代码示例。如果您正苦于以下问题:Python NavigationToolbar2QT类的具体用法?Python NavigationToolbar2QT怎么用?Python NavigationToolbar2QT使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了NavigationToolbar2QT类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: release_zoom
def release_zoom(self, event):
"""
override zoom released method
"""
self.canvas_zoom_released.emit()
NavigationToolbar2QT.release_zoom(self, event)
示例2: _update_view
def _update_view(self):
"""
view update called by home(), back() and forward()
:return:
"""
NavigationToolbar2QT._update_view(self)
self._myParent.evt_view_updated()
示例3: draw
def draw(self):
"""
Canvas is drawn called by pan(), zoom()
:return:
"""
NavigationToolbar2QT.draw(self)
self._myParent.evt_view_updated()
示例4: __init__
def __init__(self, *args, **kwargs):
NavigationToolbar2QT.__init__(self, *args, **kwargs)
self.init_buttons()
self.panAction.setCheckable(True)
self.zoomAction.setCheckable(True)
# remove the subplots action
self.removeAction( self.subplotsAction )
示例5: __init__
def __init__(self, canvas_, parent_):
# backend.figureoptions = None # Monkey patched to kill the figure options button on matplotlib toolbar
# self.toolitems = (
# ('Home', 'Reset original view', 'home', 'home'),
# ('Back', 'Back to previous view', 'back', 'back'),
# ('Forward', 'Forward to next view', 'forward', 'forward'),
# (None, None, None, None),
# ('Pan', 'Pan axes with left mouse, zoom with right', 'move', 'pan'),
# ('Zoom', 'Zoom to rectangle', 'zoom_to_rect', 'zoom'),
# (None, None, None, None),
# ('Save', 'Save the current image', 'filesave', 'save_figure'),
# )
NavigationToolbar2QT.__init__(self, canvas_, parent_)
示例6: zoom
def zoom(self, *args):
"""
Turn on/off zoom (zoom button)
:param args:
:return:
"""
NavigationToolbar2QT.zoom(self, args)
if self._myMode == NAVIGATION_MODE_ZOOM:
# out of zoom mode
self._myMode = NAVIGATION_MODE_NONE
else:
# into zoom mode
self._myMode = NAVIGATION_MODE_ZOOM
示例7: __init__
def __init__(self, parent, canvas):
""" Initialization
built-in methods
- drag_zoom(self, event): triggered during holding the mouse and moving
"""
NavigationToolbar2QT.__init__(self, canvas, canvas)
# parent
self._myParent = parent
# tool bar mode
self._myMode = NAVIGATION_MODE_NONE
# connect the events to parent
self.home_button_pressed.connect(self._myParent.evt_toolbar_home)
self.canvas_zoom_released.connect(self._myParent.evt_zoom_released)
示例8: pan
def pan(self, *args):
"""
:param args:
:return:
"""
NavigationToolbar2QT.pan(self, args)
if self._myMode == NAVIGATION_MODE_PAN:
# out of pan mode
self._myMode = NAVIGATION_MODE_NONE
else:
# into pan mode
self._myMode = NAVIGATION_MODE_PAN
print('PANNED')
示例9: MyMplCanvas
class MyMplCanvas(FigureCanvas):
"""Ultimately, this is a QWidget (as well as a FigureCanvasAgg, etc.)."""
def __init__(self, parent=None, width=5, height=4, dpi=100):
fig = Figure(figsize=(width, height), dpi=dpi)
self.axes = fig.add_subplot(111)
# We want the axes cleared every time plot() is called
self.axes.hold(False)
self.compute_initial_figure()
#
FigureCanvas.__init__(self, fig)
self.setParent(parent)
self.setStyleSheet("{background-color:transparent;border:none;}")
"""FigureCanvas.setSizePolicy(self,
QtWidgets.QSizePolicy.Expanding,
QtWidgets.QSizePolicy.Expanding)"""
FigureCanvas.updateGeometry(self)
self.tootlbar = NavigationToolbar(self, parent)
self.tootlbar.hide()
self.fid = 0
self.data = []
self.index = []
def compute_initial_figure(self):
pass
示例10: press_zoom
def press_zoom(self, event):
"""
Method that is used to limit zoom to the x axis. Based on
http://stackoverflow.com/a/16709952/5215507
"""
event.key = 'x'
NavigationToolbar.press_zoom(self, event)
示例11: matplotlibWidget
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()
示例12: __init__
def __init__(self, parent=None):
super(Widgetmain, self).__init__(parent)
self.figure = Figure()
# plt.subplots_adjust(left=0.031, right=0.999, top=0.99, bottom=0.03)
# plt.subplots_adjust(left=0.001, right=0.999, top=0.999, bottom=0.001)
self.canvas = FigureCanvas(self.figure)
self.toolbar = NavigationToolbar(self.canvas, self)
# uncomment for disabling plot toolbar, not recommended
self.toolbar.hide()
# set the layout
self.layout = QtWidgets.QVBoxLayout()
self.layout.addWidget(self.toolbar)
self.layout.addWidget(self.canvas)
self.setLayout(self.layout)
# set the plot class handlers
self.wzoom = plot_tools.WheellZoom()
self.adapt = plot_tools.WindowResize() # keep tight layout
self.cursor = plot_tools.SnaptoCursor()
self.selector = plot_tools.Select()
self.selection = plot_tools.Selection()
self.dataplot = None
示例13: addmpl
def addmpl(self, fig):
self.canvas = FigureCanvas(fig)
self.canvas.mpl_connect('button_press_event',self.on_click)
self.mplvl.addWidget(self.canvas)
self.canvas.draw()
self.toolbar = NavigationToolbar(self.canvas,self.mplwindow,coordinates=True)
self.mplvl.addWidget(self.toolbar)
示例14: addmpl
def addmpl(self):
# add plot to anvas
self.rmmpl()
self.canvas = FigureCanvas(self.fig)
self.mplvl.addWidget(self.canvas)
self.canvas.draw()
self.toolbar = NavigationToolbar(self.canvas, self.mplwindow)
self.mplvl.addWidget(self.toolbar)
示例15: __init__
def __init__(self, parent, settingsdict1={}, obsid=''):
utils.start_waiting_cursor()#show the user this may take a long time...
self.obsid = obsid
self.log_pos = None
self.y_pos = None
self.meas_ts = None
self.head_ts = None
self.head_ts_for_plot = None
self.level_masl_ts = None
self.loggerpos_masl_or_offset_state = 1
self.settingsdict = settingsdict1
qgis.PyQt.QtWidgets.QDialog.__init__(self, parent)
self.setAttribute(qgis.PyQt.QtCore.Qt.WA_DeleteOnClose)
self.setupUi(self) # Required by Qt4 to initialize the UI
self.setWindowTitle(ru(QCoreApplication.translate('Calibrlogger', "Calculate water level from logger"))) # Set the title for the dialog
self.INFO.setText(ru(QCoreApplication.translate('Calibrlogger', "Select the observation point with logger data to be adjusted.")))
self.log_calc_manual.setText("<a href=\"https://github.com/jkall/qgis-midvatten-plugin/wiki/4.-Edit-data\">Midvatten manual</a>")
# Create a plot window with one single subplot
self.calibrplotfigure = plt.figure()
self.axes = self.calibrplotfigure.add_subplot( 111 )
self.canvas = FigureCanvas( self.calibrplotfigure )
self.mpltoolbar = NavigationToolbar( self.canvas, self.widgetPlot )
self.layoutplot.addWidget( self.canvas )
self.layoutplot.addWidget( self.mpltoolbar )
self.show()
self.cid =[]
self.pushButtonSet.clicked.connect(lambda x: self.set_logger_pos())
self.pushButtonAdd.clicked.connect(lambda x: self.add_to_level_masl())
self.pushButtonFrom.clicked.connect(lambda x: self.set_from_date_from_x())
self.pushButtonTo.clicked.connect(lambda x: self.set_to_date_from_x())
self.L1_button.clicked.connect(lambda x: self.set_adjust_data('L1_date', 'L1_level'))
self.L2_button.clicked.connect(lambda x: self.set_adjust_data('L2_date', 'L2_level'))
self.M1_button.clicked.connect(lambda x: self.set_adjust_data('M1_date', 'M1_level'))
self.M2_button.clicked.connect(lambda x: self.set_adjust_data('M2_date', 'M2_level'))
self.pushButton_from_extent.clicked.connect(lambda: self.FromDateTime.setDateTime(num2date(self.axes.get_xbound()[0])))
self.pushButton_to_extent.clicked.connect(lambda: self.ToDateTime.setDateTime(num2date(self.axes.get_xbound()[1])))
self.pushButtonupdateplot.clicked.connect(lambda x: self.update_plot())
self.pushButtonLpos.clicked.connect(lambda x: self.catch_old_level())
self.pushButtonMpos.clicked.connect(lambda x: self.catch_new_level())
self.pushButtonMpos.setEnabled(False)
self.pushButtonCalcBestFit.clicked.connect(lambda x: self.logger_pos_best_fit())
self.pushButtonCalcBestFit.setToolTip(ru(QCoreApplication.translate('Calibrlogger', 'This will calibrate all values inside the chosen period\nusing the mean difference between head_cm and w_levels measurements.\n\nThe search radius is the maximum time distance allowed\n between a logger measurement and a w_level measurement.')))
self.pushButtonCalcBestFit2.clicked.connect(lambda x: self.level_masl_best_fit())
self.pushButtonCalcBestFit2.setToolTip(ru(QCoreApplication.translate('Calibrlogger', 'This will calibrate all values inside the chosen period\nusing the mean difference between level_masl and w_levels measurements.\n\nThe search radius is the maximum time distance allowed\n between a logger measurement and a w_level measurement.')))
self.pushButton_delete_logger.clicked.connect(lambda: self.delete_selected_range('w_levels_logger'))
self.adjust_trend_button.clicked.connect(lambda x: self.adjust_trend_func())
self.get_search_radius()
# Populate combobox with obsid from table w_levels_logger
self.load_obsid_from_db()
utils.stop_waiting_cursor()#now this long process is done and the cursor is back as normal