本文整理汇总了Python中matplotlib.backends.backend_qt4.NavigationToolbar2QT.setOrientation方法的典型用法代码示例。如果您正苦于以下问题:Python NavigationToolbar2QT.setOrientation方法的具体用法?Python NavigationToolbar2QT.setOrientation怎么用?Python NavigationToolbar2QT.setOrientation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.backends.backend_qt4.NavigationToolbar2QT
的用法示例。
在下文中一共展示了NavigationToolbar2QT.setOrientation方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PlotWidget
# 需要导入模块: from matplotlib.backends.backend_qt4 import NavigationToolbar2QT [as 别名]
# 或者: from matplotlib.backends.backend_qt4.NavigationToolbar2QT import setOrientation [as 别名]
class PlotWidget(QtGui.QWidget):
"""This class represents the plot view for plotting graphs.
:returns: an instance of *PlotWidget*
"""
def __init__(self,):
QtGui.QWidget.__init__(self)
self.figure = Figure(facecolor=(1, 1, 1), tight_layout=True)
self.ax = self.figure.add_subplot(111)
# Canvas
self.canvas = FigureCanvas(self.figure)
self.canvas.setSizePolicy(QtGui.QSizePolicy.Expanding,
QtGui.QSizePolicy.Expanding)
self.canvas.updateGeometry()
# Navigation
self.navi_toolbar = NavigationToolbar(self.canvas, self)
self.navi_toolbar.setOrientation(QtCore.Qt.Vertical)
# Fixed with, otherwise navigation bar resize arbitrary
self.navi_toolbar.setFixedWidth(40)
self.vbl = QtGui.QHBoxLayout()
self.vbl.addWidget(self.navi_toolbar)
self.vbl.addWidget(self.canvas)
self.setLayout(self.vbl)
def plot(self, x_data_1, y_data_1, x_data_2, y_data_2):
"""Plot given data on *PlotWidget*.
:param x_data_1: X-axis data for plot 1
:type x_data_1: array_like
:param y_data_1: Y-axis data for plot 1
:type y_data_1: array_like
:param x_data_2: X-axis data for plot 2
:type x_data_2: array_like
:param y_data_2: Y-axis data for plot 2
:type y_data_2: array_like
"""
self.ax.clear()
self.ax.grid(True)
self.ax.plot(x_data_1, y_data_1, 'b^', label='Input Data')
self.ax.plot(x_data_2, y_data_2, 'b-', label='Fitted Data')
self.ax.legend()
self.canvas.draw()
示例2: init_plots
# 需要导入模块: from matplotlib.backends.backend_qt4 import NavigationToolbar2QT [as 别名]
# 或者: from matplotlib.backends.backend_qt4.NavigationToolbar2QT import setOrientation [as 别名]
def init_plots(self):
""" Initialize plots used in plugin """
self.plot_dock = QtGui.QDockWidget('TSTools Plots',
self.iface.mainWindow())
self.plot_dock.setObjectName('TSTools Plots')
settings.plot_dirty = []
for plot in plots.plots:
self.plots.append(plot(self.iface))
settings.plot_dirty.append(False)
self.plot_tabs = QtGui.QTabWidget(self.plot_dock)
@QtCore.pyqtSlot(int)
def tab_changed(idx):
""" Updates current tab index & re-plots if needed """
settings.plot_current = idx
if settings.plot_dirty[idx]:
self.plots[idx].plot()
settings.plot_dirty[idx] = False
self.plot_tabs.currentChanged.connect(tab_changed)
for plot in self.plots:
widget = QtGui.QWidget()
layout = QtGui.QHBoxLayout()
nav = NavigationToolbar(plot, widget, coordinates=False)
nav.setOrientation(QtCore.Qt.Vertical)
nav.setSizePolicy(QtGui.QSizePolicy.Fixed,
QtGui.QSizePolicy.Fixed)
plot.setSizePolicy(QtGui.QSizePolicy.Preferred,
QtGui.QSizePolicy.Preferred)
layout.addWidget(nav)
layout.addWidget(plot)
widget.setLayout(layout)
self.plot_tabs.addTab(widget, plot.__str__())
self.plot_dock.setWidget(self.plot_tabs)
self.iface.addDockWidget(QtCore.Qt.BottomDockWidgetArea,
self.plot_dock)
示例3: MPL_Widget
# 需要导入模块: from matplotlib.backends.backend_qt4 import NavigationToolbar2QT [as 别名]
# 或者: from matplotlib.backends.backend_qt4.NavigationToolbar2QT import setOrientation [as 别名]
class MPL_Widget(QtGui.QWidget):
def __init__(self, parent = None, enableAutoScale = False, enableCSV = False, enableEdit = False, doublePlot = False, layoutDir = 'h'):
QtGui.QWidget.__init__(self, parent)
if doublePlot:
self.canvas = DoubleMyMplCanvas()
else:
self.canvas = MyMplCanvas()
self.toolbar = NavigationToolbar(self.canvas, self.canvas)
self.iconSize = QtCore.QSize(15,15)
self.toolbar.setIconSize(self.iconSize)
self.installEventFilter(EventFilter(self))
if layoutDir == 'v':
self.toolbar.setOrientation(QtCore.Qt.Vertical)
self.layout = QtGui.QHBoxLayout()
elif layoutDir == 'h':
self.layout = QtGui.QVBoxLayout()
# self.layout.addWidget(self.canvas)
# self.layout.addWidget(self.toolbar)
self.layout.addWidget(self.toolbar)
self.layout.addWidget(self.canvas)
self.setLayout(self.layout)
###############ZOOM CONTROLS ################
#This function has been disabled because of the special autoscaling requried for a custom program
#FIX THIS
if enableAutoScale:
print "Enable AutoScale"
#self.enableAutoScale()
self.span = SpanSelector(self.canvas.ax, self.onselect, 'horizontal', minspan =0.01,
useblit=True, rectprops=dict(alpha=0.5, facecolor='#C6DEFF') )
self.hZoom = False
self.span.visible = False
self.localYMax = 0
self.canvas.mpl_connect('button_press_event', self.onclick)
###########SAVING FIGURE TO CLIPBOARD##########
self.cb = None #will be used for the clipboard
self.tempPath = getHomeDir()
self.tempPath = os.path.join(self.tempPath,'tempMPL.png')
# self.mpl2ClipAction = QtGui.QAction("Save to Clipboard", self)
# self.mpl2ClipAction.setShortcut("Ctrl+C")
# self.addAction(self.mpl2ClipAction)
# QtCore.QObject.connect(self.mpl2ClipAction,QtCore.SIGNAL("triggered()"), self.mpl2Clip)
if enableEdit:
self.enableEdit()
self.lineDict = None
self.addLegend = False
#######SAVING FIGURE DATA############################
if enableCSV:
self.enableCSV()
########### HELPER FUNCTIONS #########################
# def focusOutEvent(self, event):
# print "Focus Out"
def focusEvent(self, event):
self.enableAutoScale()
self.enableZoom()
self.enableClip()
self.enableCSV()
#print "Focus In %s"%self.canvas.plotTitle
def lossFocusEvent(self, event):
self.disableAutoScale()
self.disableZoom()
self.disableClip()
self.disableCSV()
#print "Focus Out %s"%self.canvas.plotTitle
def enableClip(self):
self.mpl2ClipAction = QtGui.QAction("Save to Clipboard", self)
self.mpl2ClipAction.setShortcut("Ctrl+C")
self.addAction(self.mpl2ClipAction)
QtCore.QObject.connect(self.mpl2ClipAction,QtCore.SIGNAL("triggered()"), self.mpl2Clip)
def disableClip(self):
QtCore.QObject.disconnect(self.mpl2ClipAction,QtCore.SIGNAL("triggered()"), self.mpl2Clip)
self.removeAction(self.mpl2ClipAction)
def enableEdit(self):
self.editAction = QtGui.QAction("Edit Line Properties", self)
self.editAction.setShortcut("Ctrl+Alt+E")
self.addAction(self.editAction)
#.........这里部分代码省略.........
示例4: MPL_Widget
# 需要导入模块: from matplotlib.backends.backend_qt4 import NavigationToolbar2QT [as 别名]
# 或者: from matplotlib.backends.backend_qt4.NavigationToolbar2QT import setOrientation [as 别名]
class MPL_Widget(QtGui.QWidget):
def __init__(self, parent = None, enableAutoScale = True, enableCSV = False, enableEdit = True, doublePlot = False, layoutDir = 'h'):
QtGui.QWidget.__init__(self, parent)
if doublePlot:
self.canvas = DoubleMyMplCanvas()
else:
self.canvas = MyMplCanvas()
self.toolbar = NavigationToolbar(self.canvas, self.canvas)
# self.toolbar.hide()
self.installEventFilter(EventFilter(self))
if layoutDir == 'v':
self.toolbar.setOrientation(QtCore.Qt.Vertical)
self.layout = QtGui.QHBoxLayout()
elif layoutDir == 'h':
self.layout = QtGui.QVBoxLayout()
# self.layout.addWidget(self.canvas)
# self.layout.addWidget(self.toolbar)
self.layout.addWidget(self.toolbar)
self.layout.addWidget(self.canvas)
self.setLayout(self.layout)
##########################
self.dataLabels = None
###########SAVING FIGURE TO CLIPBOARD##########
self.cb = None #will be used for the clipboard
self.tempPath = getHomeDir()
self.tempPath = os.path.join(self.tempPath,'tempMPL.png')
if enableEdit:
self.enableEdit()
self.lineDict = None
self.addLegend = False
self.x = None#used for picker
self.y = None
#######SAVING FIGURE DATA############################
if enableCSV:
self.enableCSV()
########### HELPER FUNCTIONS #########################
self.clearPlotAction = QtGui.QAction("Clear Plot", self)
self.addAction(self.clearPlotAction)
QtCore.QObject.connect(self, QtCore.SIGNAL("triggered()"), self.clearPlot)
# def focusOutEvent(self, event):
# print "Focus Out"
def clearPlot(self):
print "Clear Plot"
self.canvas.ax.cla()
self.canvas.format_labels()
self.canvas.draw()
# def __initContextMenus__(self):
# self.clearPlotAction = QtGui.QAction("Clear Plot", self)
# self.addAction(self.clearPlotAction)
# QtCore.QObject.connect(self, QtCore.SIGNAL("triggered()"), self.clearPlot)
#
# self.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
# self.connect(self, QtCore.SIGNAL("customContextMenuRequested(QPoint)"), self.plotTabContext)
# def plotTabContext(self, point):
# '''Create a menu for mainTabWidget'''
# plotCT_menu = QtGui.QMenu("Menu", self)
# plotCT_menu.addAction(self.Zoom)
# plotCT_menu.addAction(self.actionAutoScale)
# plotCT_menu.addSeparator()
# plotCT_menu.addAction(self.clearPlotAction)
# plotCT_menu.exec_(self.mapToGlobal(point))
def focusEvent(self, event):
self.enableAutoScale()
self.enableZoom()
self.enableClip()
# self.enableCSV()
#print "Focus In %s"%self.canvas.plotTitle
def lossFocusEvent(self, event):
self.disableAutoScale()
self.disableZoom()
self.disableClip()
# self.disableCSV()
#print "Focus Out %s"%self.canvas.plotTitle
def enableClip(self):
self.mpl2ClipAction = QtGui.QAction("Save to Clipboard", self)
self.mpl2ClipAction.setShortcut("Ctrl+C")
self.addAction(self.mpl2ClipAction)
QtCore.QObject.connect(self.mpl2ClipAction,QtCore.SIGNAL("triggered()"), self.mpl2Clip)
def disableClip(self):
#.........这里部分代码省略.........