本文整理汇总了Python中matplotlib.backends.backend_qt5agg.NavigationToolbar2QT.hide方法的典型用法代码示例。如果您正苦于以下问题:Python NavigationToolbar2QT.hide方法的具体用法?Python NavigationToolbar2QT.hide怎么用?Python NavigationToolbar2QT.hide使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.backends.backend_qt5agg.NavigationToolbar2QT
的用法示例。
在下文中一共展示了NavigationToolbar2QT.hide方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MyMplCanvas
# 需要导入模块: from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT [as 别名]
# 或者: from matplotlib.backends.backend_qt5agg.NavigationToolbar2QT import hide [as 别名]
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
示例2: matplotlibWidget
# 需要导入模块: from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT [as 别名]
# 或者: from matplotlib.backends.backend_qt5agg.NavigationToolbar2QT import hide [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()
示例3: SliceWidget
# 需要导入模块: from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT [as 别名]
# 或者: from matplotlib.backends.backend_qt5agg.NavigationToolbar2QT import hide [as 别名]
class SliceWidget(FigureCanvas):
def __init__(self, parent=None, dpi=100):
# Create figure and axes, the axes should cover the entire figure size
figure = Figure(dpi=dpi, frameon=False)
self.axes = figure.add_axes((0, 0, 1, 1), facecolor='black')
# Hide the x and y axis, we just want to see the image
self.axes.get_xaxis().set_visible(False)
self.axes.get_yaxis().set_visible(False)
# Initialize the parent FigureCanvas
FigureCanvas.__init__(self, figure)
self.setParent(parent)
# Set background of the widget to be close to black
# The color is not made actually black so that the user can distinguish the image bounds from the figure bounds
self.setStyleSheet('background-color: #222222;')
# Set widget to have strong focus to receive key press events
self.setFocusPolicy(Qt.StrongFocus)
# Create navigation toolbar and hide it
# We don't want the user to see the toolbar but we are making our own in the user interface that will call
# functions from the toolbar
self.toolbar = NavigationToolbar(self, self)
self.toolbar.hide()
# Update size policy and geometry
FigureCanvas.setSizePolicy(self, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
FigureCanvas.updateGeometry(self)
self.isLPS = False
self.isLAS = False
self.image = None
self.sliceNumber = 0
self.diaphragmAxial = None
self.umbilicisInferior = None
self.umbilicisSuperior = None
self.umbilicisLeft = None
self.umbilicisRight = None
self.umbilicisCoronal = None
self.CATLine = None
self.leftArmBounds = None
self.rightArmBounds = None
def updateFigure(self):
# Clear the axes
self.axes.cla()
# Draw the image if it is set
if self.image is not None:
image = self.image[self.sliceNumber, :, :]
# For viewing, we use right-anterior-superior (RAS) system. This is the same system that PATS uses.
# For LPS volumes, we reverse the x/y axes to go from LPS to RAS.
# Also, TTU data is in LAS which is odd but handle that too
if self.isLPS:
image = image[::-1, ::-1]
elif self.isLAS:
image = image[:, ::-1]
self.axes.imshow(image, cmap='gray', origin='lower')
# Draw rectangle on the diaphragm slice
if self.sliceNumber == self.diaphragmAxial:
self.axes.add_patch(patches.Rectangle((0, 0), 20, 20, color='purple'))
# Draw a line where the umbilicis is set to be
if self.umbilicisInferior is not None and self.umbilicisSuperior is not None and \
self.umbilicisCoronal is not None and self.umbilicisLeft is not None and \
self.umbilicisRight is not None:
if self.umbilicisInferior <= self.sliceNumber <= self.umbilicisSuperior:
x = self.umbilicisLeft
y = self.umbilicisCoronal
width = self.umbilicisRight - x
height = 1
self.axes.add_patch(patches.Rectangle((x, y), width, height, color='orange'))
# Draw lines for the CAT bounding box configuration
if self.CATLine is not None and len(self.CATLine) > 1:
startIndex = next((i for i, x in enumerate(self.CATLine) if min(x) != -1), None)
CATLine = self.CATLine[startIndex:]
if len(CATLine) > 1 and CATLine[0][0] <= self.sliceNumber <= CATLine[-1][0]:
posterior = int(np.round(np.interp(self.sliceNumber, np.array([i[0] for i in CATLine]),
np.array([i[1] for i in CATLine]))))
anterior = int(np.round(np.interp(self.sliceNumber, np.array([i[0] for i in CATLine]),
np.array([i[2] for i in CATLine]))))
x = self.image.shape[2] // 2.5
y = posterior
width = 75
height = 1
self.axes.add_patch(patches.Rectangle((x, y), width, height, color='red'))
y = anterior
self.axes.add_patch(patches.Rectangle((x, y), width, height, color='red'))
# Draw a line for the left arm bounds at the current slice
#.........这里部分代码省略.........
开发者ID:SIUE-BiomedicalImagingResearchLab,项目名称:SIUE-Dixon-Fat-Segmentation-Algorithm,代码行数:103,代码来源:sliceWidget.py
示例4: MplGraphQt5Widget
# 需要导入模块: from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT [as 别名]
# 或者: from matplotlib.backends.backend_qt5agg.NavigationToolbar2QT import hide [as 别名]
class MplGraphQt5Widget(QWidget):
def __init__(self, parent=None):
super(MplGraphQt5Widget, self).__init__(parent)
self.width = 3
self.height = 3
self.dpi = 100
self._dataY = np.array([])
self._dataX = np.array([])
self._spCols = 1
self._spRows = 1
self.all_sp_axes = []
self.fig = Figure(figsize=(self.width, self.height), dpi=self.dpi)
self.all_sp_axes.append(self.fig.add_subplot(self._spCols, self._spRows, 1))
self.fig.set_frameon(False)
self.fig.set_tight_layout(True)
self.canvas = Canvas(self.fig)
self._navBarOn = False
self.mpl_toolbar = NavigationToolbar(self.canvas, parent)
self.mpl_toolbar.dynamic_update()
self.canvas.mpl_connect('key_press_event', self.on_key_press)
self.canvas.mpl_connect('button_press_event', self.on_button_press)
self.canvas.mpl_connect('motion_notify_event', self.on_mouse_move)
self.canvas.setFocusPolicy(Qt.ClickFocus)
self.canvas.setFocus()
self.canvas.setParent(parent)
self.canvas.clearMask()
self.canvas.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
self.canvas.updateGeometry()
vbox = QVBoxLayout()
vbox.addWidget(self.canvas)
vbox.addWidget(self.mpl_toolbar)
if not self._navBarOn:
self.mpl_toolbar.hide()
self.setLayout(vbox)
def get_icon(name):
"""Return Matplotlib icon *name*"""
return QIcon(osp.join(rcParams['datapath'], 'images', name))
key_pressed = pyqtSignal(object, name='keyPressed')
def on_key_press(self, event):
self.key_pressed.emit(event)
key_press_handler(event, self.canvas, self.mpl_toolbar)
button_pressed = pyqtSignal(object, name='buttonPressed')
def on_button_press(self, event):
self.button_pressed.emit(event)
key_press_handler(event, self.canvas, self.mpl_toolbar)
mouse_move = pyqtSignal(object, name='mouseMoved')
def on_mouse_move(self, event):
self.mouse_move.emit(event)
key_press_handler(event, self.canvas, self.mpl_toolbar)
def generateNewAxes(self):
for ax in self.all_sp_axes:
self.fig.delaxes(ax)
self.all_sp_axes = []
numOfAxes = (self._spRows*self._spCols)+1
for i in np.arange(1,numOfAxes):
self.all_sp_axes.append(self.fig.add_subplot(self._spRows, self._spCols, i))
self.canvas.setGeometry(100, 100, 300, 300) #Used to update the new number of axes
self.canvas.updateGeometry() #This will bring the size of the canvas back to the original (defined by the vbox)
spRowsChanged = pyqtSignal(int)
def getspRows(self):
return self._spRows
@pyqtSlot(int)
def setspRows(self, spRows):
self._spRows = spRows
self.generateNewAxes()
self.spRowsChanged.emit(spRows)
def resetspRows(self):
self.setspRows(1)
spRows = pyqtProperty(int, getspRows, setspRows, resetspRows)
spColsChanged = pyqtSignal(int)
def getspCols(self):
return self._spCols
#.........这里部分代码省略.........
示例5: Widgetmain
# 需要导入模块: from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT [as 别名]
# 或者: from matplotlib.backends.backend_qt5agg.NavigationToolbar2QT import hide [as 别名]
class Widgetmain(QtWidgets.QWidget):
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
def setStatus(self, stat):
self.statusbar = stat
def save_plot(self):
self.toolbar.save_figure()
def axis_configure(self):
self.toolbar.edit_parameters()
def plot(self, xaxis=None, real=None, imag=None, magn=None, hxlimit=None, lxlimit=None, datas=None):
# self.dataplot.clear()
# if self.dataplot:
# self.figure.delaxes(self.dataplot)
if self.dataplot is None:
self.dataplot = self.figure.add_subplot(111)
self.figure.patch.set_facecolor("white")
self.selector.setAx(self.dataplot, hxlimit, lxlimit, xaxis.size, datas, self.selection)
# self.dataplot = self.figure.add_subplot(111)
# self.selector.setAx(self.dataplot, hxlimit, lxlimit, xaxis.size, datas, self.selection)
self.statusbar.showMessage("Plot updated")
self.dataplot.hold(False)
self.dataplot.plot(xaxis, real, "r-", xaxis, imag, "g-", xaxis, magn, "-")
# uncomment for matlibplot standard cursor
# cursor = Cursor(dataplot, useblit=True, color='black', linewidth=1 )
self.wzoom.setAx(self.dataplot, self.selection, datas)
self.cursor.setAx(datas, self.dataplot, xaxis, real, self.statusbar)
self.adapt.setAx(self.dataplot, self.figure)
self.selection.setAx(self.dataplot, datas)
self.figure.tight_layout()
# dataplot.set_autoscaley_on(False) for auto x scale
# setting background color
# self.figure.patch.set_visible(False)
# self.figure.patch.set_facecolor('white')
self.dataplot.set_xlim([lxlimit, hxlimit])
# uncomment the following line for raw axis label inside plot
# self.dataplot.tick_params(direction='in', pad=-19)
# uncomment the following lines to disable plot toolbar mouse coordinates
# def format_coord(x, y):
# return ' '
# self.dataplot.format_coord = format_coord
self.canvas.draw()
示例6: Ui_MainWindow
# 需要导入模块: from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT [as 别名]
# 或者: from matplotlib.backends.backend_qt5agg.NavigationToolbar2QT import hide [as 别名]
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName(_fromUtf8("Data View"))
#MainWindow.resize(539, 600)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
self.verticalLayout = QtWidgets.QVBoxLayout(self.centralwidget)
self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
self.splitter = QtWidgets.QSplitter(self.centralwidget)
self.splitter.setOrientation(QtCore.Qt.Horizontal)
self.splitter.setObjectName(_fromUtf8("splitter"))
# File navigation
self.fileSystemModel = QtWidgets.QDirModel(self.splitter)
self.fileSystemModel.setObjectName(_fromUtf8("fileSystemModel"))
currentDir = str(QtCore.QDir.currentPath())
index = self.fileSystemModel.index(currentDir)
self.treeView = QtWidgets.QTreeView(self.splitter)
self.treeView.setObjectName(_fromUtf8("treeView"))
self.treeView.setModel(self.fileSystemModel)
if len(sys.argv)>1:
self.currentFile = currentDir + '/' + sys.argv[1]
else:
self.currentFile = None
self.recursive_expand( index, self.treeView )
tVheader = self.treeView.header()
for i in range(1,4): tVheader.hideSection(i)
self.treeView.doubleClicked.connect(self.on_treeView_doubleClicked)
# Plots tab
self.tabWidget = QtWidgets.QTabWidget(self.splitter)
self.tabWidget.setObjectName(_fromUtf8("tabWidget"))
self.tab = QtWidgets.QWidget()
self.tab.setObjectName(_fromUtf8("tab"))
self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.tab)
self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2"))
self.figure = plt.figure(figsize=(15,5))
self.canvas = FigureCanvas(self.figure)
self.canvas.setObjectName(_fromUtf8("canvas"))
self.toolbar = NavigationToolbar(self.canvas, self)
self.toolbar.hide()
self.verticalLayout_2.addWidget(self.canvas)
# Plot buttons
self.horizontalLayout = QtWidgets.QHBoxLayout()
self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout_plotButtons"))
self.plotTypeCombo = QtWidgets.QComboBox(self.tab)
self.plotTypeCombo.setObjectName(_fromUtf8("plotTypeCombo"))
self.plotTypeCombo.currentIndexChanged.connect(self.ChangePlotType)
self.horizontalLayout.addWidget(self.plotTypeCombo)
self.btnPlot = QtWidgets.QPushButton(self.tab)
self.btnPlot.setObjectName(_fromUtf8("btnPlot"))
self.btnPlot.clicked.connect(self.drawPlot)
self.horizontalLayout.addWidget(self.btnPlot)
self.btnZoom = QtWidgets.QPushButton(self.tab)
self.btnZoom.setObjectName(_fromUtf8("btnZoom"))
self.btnZoom.clicked.connect(self.plotZoom)
self.horizontalLayout.addWidget(self.btnZoom)
self.btnPan = QtWidgets.QPushButton(self.tab)
self.btnPan.setObjectName(_fromUtf8("btnPan"))
self.btnPan.clicked.connect(self.plotPan)
self.horizontalLayout.addWidget(self.btnPan)
self.btnHome = QtWidgets.QPushButton(self.tab)
self.btnHome.setObjectName(_fromUtf8("btnHome"))
self.btnHome.clicked.connect(self.plotHome)
self.horizontalLayout.addWidget(self.btnHome)
self.verticalLayout_2.addLayout(self.horizontalLayout)
# x axis options
self.horizontalLayout_xAxis = QtWidgets.QHBoxLayout()
self.horizontalLayout_xAxis.setObjectName(_fromUtf8("horizontalLayout_xAxis"))
self.xColSelect = QtWidgets.QComboBox(self.tab)
self.xColSelect.setObjectName(_fromUtf8("xColSelect"))
self.xColSelect.currentIndexChanged.connect(self.ResetUserSelections)
self.horizontalLayout_xAxis.addWidget(self.xColSelect)
self.horizontalLayout_xAxis.setStretchFactor(self.xColSelect,2)
self.xbinsLabel = QtWidgets.QLabel(self.tab)
self.xbinsLabel.setText("X Bins:")
self.horizontalLayout_xAxis.addWidget( self.xbinsLabel )
self.xnBinsSpin = QtWidgets.QSpinBox(self.tab)
self.xnBinsSpin.setObjectName(_fromUtf8("xnBinsSpin"))
self.xnBinsSpin.valueChanged.connect(self.XChangeBinning)
self.xnBinsSpin.setRange(1,10000)
self.horizontalLayout_xAxis.addWidget( self.xnBinsSpin )
self.horizontalLayout_xAxis.setStretchFactor(self.xnBinsSpin,2)
self.xminLabel = QtWidgets.QLabel(self.tab)
self.xminLabel.setText("X Min:")
self.horizontalLayout_xAxis.addWidget( self.xminLabel )
self.xnMinSpin = QtWidgets.QDoubleSpinBox(self.tab)
self.xnMinSpin.setObjectName(_fromUtf8("xnMinSpin"))
self.xnMinSpin.valueChanged.connect(self.XChangeMin)
self.xnMinSpin.setRange( -1e20, 1e20 )
self.horizontalLayout_xAxis.addWidget( self.xnMinSpin )
self.horizontalLayout_xAxis.setStretchFactor(self.xnMinSpin,2)
self.xmaxLabel = QtWidgets.QLabel(self.tab)
self.xmaxLabel.setText("X Max:")
self.horizontalLayout_xAxis.addWidget( self.xmaxLabel )
self.xnMaxSpin = QtWidgets.QDoubleSpinBox(self.tab)
#.........这里部分代码省略.........
示例7: CustomPlot
# 需要导入模块: from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT [as 别名]
# 或者: from matplotlib.backends.backend_qt5agg.NavigationToolbar2QT import hide [as 别名]
class CustomPlot(QDialog):
"""
Class used to create a plot window
Data is read from session object
"""
_colors = ['#FF0000', '#0000FF', '#00FF00', '#00002C', '#FF1AB9',
'#FFD300', '#005800', '#8484FF', '#9E4F46', '#00FFC1',
'#008495', '#00007B', '#95D34F', '#F69EDC', '#D312FF']
def __init__(self, parent, session):
"""
Create plot window
:param parent: Parent window object
:param session: Session object to plot data from
"""
super(CustomPlot, self).__init__(parent)
self.amp = []
self.peak_time = []
self.fwhm = []
self.regular = []
self.smooth = []
self.sem = []
self.scroll = 3
self.ui = Ui_Dialog()
self.ui.setupUi(self)
self.used_colors = []
self.session = session
self.fig = plt.figure()
self.current_ax = self.fig.add_subplot(111)
self.axes = {}
self.ax_list = []
self.add_ax(self.current_ax)
self.ui.toolButton_anatomy.hide()
if session.anatomy is not None:
self.ui.toolButton_anatomy.show()
self.canvas = FigureCanvas(self.fig)
self.toolbar = NavigationToolbar(self.canvas, self, coordinates=True)
self.toolbar.hide()
self.ui.mplvl.addWidget(self.canvas)
self.ui.checkBox_fwhm.clicked.connect(self.plot_fwhm)
self.ui.checkBox_sem.clicked.connect(self.plot_sem)
self.ui.checkBox_regular.clicked.connect(self.replot)
self.ui.checkBox_smooth.clicked.connect(self.replot)
self.ui.checkBox_amp.clicked.connect(self.plot_amplitude)
self.ui.checkBox_peak.clicked.connect(self.plot_peak)
self.ui.stimuliBox.currentTextChanged.connect(self.replot)
self.ui.mean_response_btn.clicked.connect(self.replot)
self.ui.several_responses_btn.clicked.connect(self.replot)
self.ui.checkBox_labels.clicked.connect(self.show_legends)
self.ui.label_size.valueChanged.connect(self.show_legends)
self.ui.spinBox.valueChanged.connect(self.replot)
self.ui.toolButton_home.clicked.connect(self.toolbar.home)
self.ui.toolButton_export.clicked.connect(self.tool_export)
self.ui.toolButton_pan.clicked.connect(self.toolbar.pan)
self.ui.toolButton_zoom.clicked.connect(self.toolbar.zoom)
self.ui.toolButton_anatomy.clicked.connect(self.tool_anatomy)
self.setWindowTitle('Plot - ' + session.name)
self.export_window = None
self.add_stimuli_types()
# Enable the 'plot several' button if the object has more than 1 child
children = self.session.children + self.session.sessions
if children and len(children) > 1:
self.ui.several_responses_btn.setEnabled(True)
else:
self.ui.several_responses_btn.hide()
self.ui.toolButton_add_subplot.clicked.connect(self.add_subplot)
self.ui.toolButton_rem_subplot.clicked.connect(self.remove_subplot)
# Move the subplot to make space for the legend
self.fig.subplots_adjust(right=0.8)
self.canvas.mpl_connect('button_press_event', self.click_plot)
self.fig.tight_layout(pad=2.0)
# Change default value in smooth wheel if percent is used
if self.session.get_setting("percent"):
self.ui.spinBox.setValue(2)
self.replot()
self.show()
self.ui.verticalLayout_3.update()
#.........这里部分代码省略.........