本文整理汇总了Python中matplotlib.backends.backend_qt4agg.NavigationToolbar2QT类的典型用法代码示例。如果您正苦于以下问题:Python NavigationToolbar2QT类的具体用法?Python NavigationToolbar2QT怎么用?Python NavigationToolbar2QT使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了NavigationToolbar2QT类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, plotCanvas, parent, custom_actions=True):
"""
**Properties**
*_firstChange* (boolean):
Whether or not the y limits of the plots were
changed before.
*_plot_params* (dictionary):
The plot parameters given as (key, value) pare.
"""
NavigationToolbar2QTAgg.__init__(self, plotCanvas, parent)
# properties {
self._firstChange = True
self._plot_params = {}
# }
# custom actions {
if custom_actions:
self.addSeparator()
self.action_reset = self.addAction("Reset", self.onReset)
self.action_reset.setToolTip("Reset the y limits")
self.action_plus = self.addAction("+", self.onPlus)
self.action_plus.setToolTip("Expand the y limits")
self.action_minus = self.addAction("-", self.onMinus)
self.action_minus.setToolTip("Reduce the y limits")
示例2: __init__
def __init__(self, canvas, parent, coordinates=True):
NavigationToolbar2QT.__init__(self, canvas, parent, coordinates)
self.setIconSize(QtCore.QSize(16, 16))
self.ct = None
self.mw = None
self._idPress1 = None
self._idPress2 = None
self._idPress3 = None
示例3: __init__
def __init__(self, canvas, parent, browser):
NavigationToolbar2QT.__init__(self,canvas,parent)
for c in self.findChildren(QtGui.QToolButton):
#print str(c.text())
#if str(c.text()) in ('Subplots','Customize','Back','Forward','Home'):
if str(c.text()) in ('Customize','Back','Forward'):
c.defaultAction().setVisible(False)
self.parent = parent
self.browser = browser
示例4: __init__
def __init__(self, canvas, parent ):
NavigationToolbar2QT.__init__(self,canvas,parent)
self.clearButtons=[]
# Search through existing buttons
# next use for placement of custom button
next=None
for c in self.findChildren(QToolButton):
if next is None:
next=c
# Don't want to see subplots and customize
if str(c.text()) in ('Subplots','Customize','Forward', 'Back'):
c.defaultAction().setVisible(False)
continue
示例5: __init__
def __init__(self, canvas_, parent_):
override.figureoptions = None # Monkey patched to kill the figure options button on matplotlib toolbar
self.toolitems = (
('Home', 'Reset original view', 'home', 'home'),
('Save', 'Save the current image', 'filesave', 'save_figure'),
(None, None, None, None),
('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'),
)
NavigationToolbar2QT.__init__(self, canvas_, parent_)
示例6: __init__
def __init__(self, parent=None):
super(Window, self).__init__(parent)
#Variables Init
self.figure = plt.figure()
self.ax = self.figure.add_subplot(111)
canvas = FigureCanvas(self.figure)
self.mat = self.ax.matshow(np.zeros((num_rows,num_cols)))
#global ax, mat, ser, Array, data
toolbar = NavigationToolbar(canvas, self)
toolbar.hide()
# Start Button
self.button = QtGui.QPushButton('Start')
self.button.clicked.connect(plot)
#self.button1 = QtGui.QPushButton('Record')
#self.button.clicked.connect(self.plot)
# set the layout
layout = QtGui.QVBoxLayout()
layout.addWidget(canvas)
layout.addWidget(self.button)
self.setLayout(layout)
self.figure.canvas.draw()
self.timer = self.startTimer(3)
示例7: addSeventyLine
def addSeventyLine(self):
global seventyLine
if(seventyLine == True):
seventyLine = False
self.rsiGraph.setParent(None)
self.candlestick.setParent(None)
self.toolbar.setParent(None)
self.splitter1.setParent(None)
self.candlestick = mainGraphCanvas(self.main_widget)
self.rsiGraph = rsiGraphCanvas(self.main_widget)
self.toolbar = NavigationToolbar(self.candlestick, self.main_widget)
self.splitter1 = QtGui.QSplitter(QtCore.Qt.Vertical)
self.splitter1.addWidget(self.candlestick)
self.splitter1.addWidget(self.rsiGraph)
self.splitter1.addWidget(self.toolbar)
self.graphVBox.addWidget(self.splitter1)
self.rsi.show()
else:
seventyLine = True
self.rsiGraph.setParent(None)
self.candlestick.setParent(None)
self.toolbar.setParent(None)
self.splitter1.setParent(None)
self.candlestick = mainGraphCanvas(self.main_widget)
self.rsiGraph = rsiGraphCanvas(self.main_widget)
self.toolbar = NavigationToolbar(self.candlestick, self.main_widget)
self.splitter1 = QtGui.QSplitter(QtCore.Qt.Vertical)
self.splitter1.addWidget(self.candlestick)
self.splitter1.addWidget(self.rsiGraph)
self.splitter1.addWidget(self.toolbar)
self.graphVBox.addWidget(self.splitter1)
self.rsi.show()
示例8: MatplotlibWidgetWFPot
class MatplotlibWidgetWFPot(QtGui.QGraphicsView):
def __init__(self, parent = None):
QtGui.QWidget.__init__(self, parent)
self.canvas = MplCanvas()
self.vbl = QtGui.QVBoxLayout()
self.vbl.addWidget(self.canvas)
self.setLayout(self.vbl)
self.canvas.ax.set_title('Calculated PCB electrode potentials', fontsize=10)
self.canvas.fig.patch.set_alpha(0)
self.mpl_toolbar = NavigationToolbar(self.canvas, self)
params = {
'legend.fontsize': 8,
'xtick.labelsize': 8,
'ytick.labelsize': 8,
'legend.handletextpad': .5,
}
plt.rcParams.update(params)
self.mpl_toolbar.pan()
def plot(self, wfPotentials, plotitems):
if hasattr(wfPotentials, 'plotTime'):
argX = wfPotentials.plotTime
argY = wfPotentials.potentialsOut
# get axis limits to not reset zoom/pan
axlim = self.canvas.ax.axis()
self.canvas.ax.clear()
if not any(plotitems):
self.canvas.draw()
return
if plotitems[0]:
self.canvas.ax.plot(argX, argY[1,:], 'r.')
self.canvas.ax.plot(argX, argY[1,:], 'r', label="2", linewidth=1.2)
if plotitems[1]:
self.canvas.ax.plot(argX, argY[3,:], 'b.')
self.canvas.ax.plot(argX, argY[3,:], 'b', label="4", linewidth=1.2)
if plotitems[2]:
self.canvas.ax.plot(argX, argY[5,:], 'g.')
self.canvas.ax.plot(argX, argY[5,:], 'g', label="6", linewidth=1.2)
if not axlim == (0.0, 1.0, 0.0, 1.0):
self.canvas.ax.axis(axlim)
else: pass
self.canvas.ax.grid(True)
self.canvas.ax.set_title("Calculated PCB electrode potentials", fontsize=10)
self.canvas.ax.set_xlabel("Time ($\mu$s)", fontsize=10)
self.canvas.ax.set_ylabel("Amplitude (bits)", fontsize=10)
self.canvas.ax.legend(bbox_to_anchor=(0.02, 0.99), loc=2, borderpad=None, borderaxespad=0., fontsize=8, frameon=False)
# mares in potential generation
self.canvas.ax.plot([wfPotentials.incplTime,wfPotentials.incplTime],[(wfPotentials.maxAmp*2+50),-50], 'k--', linewidth=1.5)
self.canvas.ax.plot([wfPotentials.plotTime[-1]-wfPotentials.outcplTime, wfPotentials.plotTime[-1]-wfPotentials.outcplTime], \
[-1,wfPotentials.maxAmp*2+1], 'k--', linewidth=1.5)
#self.WaveformDisplay.canvas.ax.plot([wfPotentials.incplTime+wfPotentials.decelTime,\
#wfPotentials.incplTime+wfPotentials.decelTime],[wfPotentials.maxAmp*-2-1, wfPotentials.maxAmp*2+1], 'k--', linewidth=1)
self.canvas.fig.patch.set_alpha(0)
self.canvas.fig.tight_layout()
self.canvas.draw()
else:
print 'No potentials generated'
示例9: __init__
def __init__(self, parent, canvas):
""" Initialization
"""
NavigationToolbar2.__init__(self, canvas, canvas)
self._myParent = parent
self._navigationMode = MyNavigationToolbar.NAVIGATION_MODE_NONE
return
示例10: __init__
def __init__(self, canvas, window, profile=True):
self.toolitems = list(self.toolitems)
self.toolitems.insert(6, ('Profile', 'Get the profile of a line in an image',
os.path.join(imgutils.RESSOURCE_PATH, "profile"), 'profile'))
self.toolitems.insert(7, ('Stats', 'Get statistics on a portion of an image/line',
os.path.join(imgutils.RESSOURCE_PATH, "stats"), 'stats'))
NavigationToolbar.__init__(self, canvas, window)
self._actions['profile'].setCheckable(True)
self._actions['stats'].setCheckable(True)
示例11: _update_view
def _update_view(self):
"""
view update called by home(), back() and forward()
:return:
"""
NavigationToolbar2._update_view(self)
self._myParent.evt_view_updated()
return
示例12: draw
def draw(self):
"""
Canvas is drawn called by pan(), zoom()
:return:
"""
NavigationToolbar2.draw(self)
self._myParent.evt_view_updated()
return
示例13: MplWidgetT
class MplWidgetT(QtGui.QWidget):
def __init__(self, parent = None):
QtGui.QWidget.__init__(self, parent)
self.canvas = MplCanvas()
self.ntb = NavigationToolbar(self.canvas, self)
self.ntb.setIconSize(QtCore.QSize(16, 16))
self.vbl = QtGui.QVBoxLayout()
self.vbl.addWidget(self.canvas)
self.vbl.addWidget(self.ntb)
self.setLayout(self.vbl)
示例14: __init__
def __init__(self , parent , canvas , orientation = Qt.Vertical,
close_button = False) :
"""
A simple matplotlib navigation toolbar that can be vertical
Qt.Vertical or Qt.Horizontal
"""
NavigationToolbar2.__init__( self, canvas,parent )
self.setOrientation(orientation)
if close_button:
self.addSeparator()
self.actionClose = self.addAction(QIcon(':/window-close.png'), 'Close')
示例15: Mpl
class Mpl(QtGui.QWidget, Ui_Form):
def __init__(self, fig_dict, name_list):
super(Mpl, self).__init__()
self.setupUi(self)
self.fig_dict = fig_dict
self.name_list = name_list
self.index = 0
self.btnBack.clicked.connect(self.back)
self.btnForward.clicked.connect(self.forward)
self.comboBoxSelect.addItems(self.name_list)
self.comboBoxSelect.setCurrentIndex(self.index)
self.comboBoxSelect.activated.connect(self.select)
if self.fig_dict and self.name_list:
fig = self.fig_dict[self.name_list[self.index]]
else:
fig = Figure()
self.addmpl(fig)
def changefig(self,):
self.comboBoxSelect.setCurrentIndex(self.index)
fig = self.fig_dict[self.name_list[self.index]]
self.rmmpl()
self.addmpl(fig)
def addmpl(self, fig):
self.canvas = FigureCanvas(fig)
# self.canvas.setSizePolicy(QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Expanding)
self.ltMPL.addWidget(self.canvas)
self.canvas.draw()
self.toolbar = NavigationToolbar(self.canvas,
self.wgtToolbox, coordinates=True)
self.ltToolbox.addWidget(self.toolbar)
def rmmpl(self,):
self.ltMPL.removeWidget(self.canvas)
self.canvas.close()
self.ltToolbox.removeWidget(self.toolbar)
self.toolbar.close()
def back(self):
self.index = self.index-1 if self.index!=0 else len(self.name_list)-1
self.changefig()
def forward(self):
self.index = self.index+1 if self.index!=len(self.name_list)-1 else 0
self.changefig()
def select(self):
self.index = self.comboBoxSelect.currentIndex()
self.changefig()