本文整理汇总了Python中matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg.setMinimumSize方法的典型用法代码示例。如果您正苦于以下问题:Python FigureCanvasQTAgg.setMinimumSize方法的具体用法?Python FigureCanvasQTAgg.setMinimumSize怎么用?Python FigureCanvasQTAgg.setMinimumSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg
的用法示例。
在下文中一共展示了FigureCanvasQTAgg.setMinimumSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import setMinimumSize [as 别名]
def __init__(self, scrollAreaWidgetContents, name):
QtGui.QWidget.__init__(self)
self.setParent(scrollAreaWidgetContents)
fig = Figure((3.0, 2.0), dpi=100)
canvas = FigureCanvas(fig)
canvas.setParent(self)
toolbar = myNavigationToolbar(canvas, self)
axes = fig.add_subplot(111)
axes.autoscale(True)
axes.set_yscale('log')
axes.set_title(name)
axes.set_xlabel('Time [s]')
axes.set_ylabel('|R|')
# place plot components in a layout
plotLayout = QtGui.QVBoxLayout()
plotLayout.addWidget(canvas)
plotLayout.addWidget(toolbar)
self.setLayout(plotLayout)
self.dataPlot = []
self.dirList = []
self.dirType = 'Residuals'
self.lastPos = -1
self.name = name
self.colors = ['r', 'b', 'k', 'g', 'y', 'c']
# prevent the canvas to shrink beyond a point
#original size looks like a good minimum size
canvas.setMinimumSize(canvas.size())
示例2: __init__
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import setMinimumSize [as 别名]
def __init__(self, scrollAreaWidgetContents, dataname):
QtGui.QWidget.__init__(self)
self.setParent(scrollAreaWidgetContents)
fig = Figure((3.0, 2.0), dpi=100)
canvas = FigureCanvas(fig)
canvas.setParent(self)
toolbar = myNavigationToolbar(canvas, self)
temporal_toolbar = temporalNavigationToolbar(canvas, self)
axes = fig.add_subplot(111)
axes.autoscale(True)
axes.set_yscale('log')
axes.set_title(dataname)
# place plot components in a layout
plotLayout = QtGui.QVBoxLayout()
plotLayout.addWidget(temporal_toolbar)
plotLayout.addWidget(canvas)
plotLayout.addWidget(toolbar)
self.setLayout(plotLayout)
canvas.setMinimumSize(canvas.size())
self.name = dataname
self.dirList = []
self.dirType = 'Sampled Line'
self.lastPos = -1
self.colors = ['r', 'b', 'k', 'g', 'y', 'c']
self.labels = ['_x','_y','_z']
示例3: __init__
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import setMinimumSize [as 别名]
def __init__(self, scrollAreaWidgetContents, currentFolder):
QtGui.QWidget.__init__(self)
self.setParent(scrollAreaWidgetContents)
canvas = FigureCanvas(Figure((3.0, 2.0), dpi=100))
canvas.setParent(self)
toolbar = myNavigationToolbar(canvas, self)
toolbar.disableButtons()
temporal_toolbar = temporalNavigationToolbar(canvas, self)
mainImage = QtGui.QLabel(self)
mainImage.setText(_fromUtf8(""))
mainImage.setPixmap(QtGui.QPixmap(_fromUtf8(":/newPrefix/images/fromHelyx/emptyFigure.png")))
mainImage.setObjectName(_fromUtf8("mainImage"))
mainImage.setScaledContents(True)
mainImage.setSizePolicy(QtGui.QSizePolicy.Ignored,QtGui.QSizePolicy.Ignored)
plotLayout = QtGui.QVBoxLayout()
plotLayout.addWidget(temporal_toolbar)
plotLayout.addWidget(mainImage,1)
plotLayout.addWidget(toolbar,0,QtCore.Qt.AlignCenter)
self.setLayout(plotLayout)
self.lastPos = -1
self.dirList = []
self.currentFolder = currentFolder
canvas.setMinimumSize(canvas.size())
示例4: __init__
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import setMinimumSize [as 别名]
def __init__(self, scrollAreaWidgetContents, dataname, currentFolder):
QtGui.QWidget.__init__(self)
self.setParent(scrollAreaWidgetContents)
fig = Figure((3.0, 2.0), dpi=100)
canvas = FigureCanvas(fig)
canvas.setParent(self)
toolbar = myNavigationToolbar(canvas, self)
temporal_toolbar = temporalNavigationToolbar(canvas, self)
axes = fig.add_subplot(111)
axes.autoscale(True)
axes.set_yscale('log')
axes.set_title(dataname)
# place plot components in a layout
plotLayout = QtGui.QVBoxLayout()
plotLayout.addWidget(temporal_toolbar)
plotLayout.addWidget(canvas,1)
plotLayout.addWidget(toolbar,0,QtCore.Qt.AlignCenter)
self.setLayout(plotLayout)
canvas.setMinimumSize(canvas.size())
self.name = dataname
self.dirList = []
self.dirType = 'Sampled Line'
self.lastPos = -1
self.colors = ['r', 'b', 'k', 'g', 'y', 'c']
self.labels = ['x','y','z']
self.currentFolder = currentFolder
filename = '%s/system/controlDict'%(self.currentFolder)
parsedData = ParsedParameterFile(filename,createZipped=False)
self.ifield=parsedData['functions'][dataname]['fields'][0]
self.archifield = 'data_%s.xy'%self.ifield
示例5: plot_file
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import setMinimumSize [as 别名]
def plot_file(fps, base_dir, string_graph_map):
app = QtGui.QApplication('Bodysim')
graph_map = ast.literal_eval(string_graph_map)
# Find the length of the simulation by looking at trajectory results.
start_frame = 1
count = 0
with open(base_dir + os.sep + 'Trajectory' + os.sep + graph_map.keys()[0] + '.csv') as f:
iterF = iter(f)
# Skip header
next(iterF)
line = next(iterF)
start_frame = float(line.split(',')[0])
count = sum(1 for line in iterF)
frame = MainWindow(start_frame, count)
for sensor in graph_map:
layout_contents = frame.add_tab(sensor)
for plugin in graph_map[sensor]:
data = get_data(base_dir + os.sep + plugin + os.sep + sensor + '.csv')
for variable_group in graph_map[sensor][plugin]:
qfigWidget = QtGui.QWidget(layout_contents[1])
fig = Figure((5.0, 4.0), dpi=100)
canvas = FigureCanvas(fig)
canvas.setParent(qfigWidget)
toolbar = NavigationToolbar(canvas, qfigWidget)
axes = fig.add_subplot(111)
axes.set_title(plugin + ' ' + variable_group[2])
yDatum = [data[variable[1]] for variable in graph_map[sensor][plugin][variable_group]]
yLabels = [variable[0] for variable in graph_map[sensor][plugin][variable_group]]
for i in range(len(yDatum)):
axes.plot(data[0], yDatum[i], label=yLabels[i])
axes.grid(True)
axes.legend()
axes.autoscale(enable=False, axis='both')
axes.set_xlabel(variable_group[0])
axes.set_ylabel(variable_group[1])
# Place plot components in a layout
plotLayout = QtGui.QVBoxLayout()
plotLayout.addWidget(canvas)
plotLayout.addWidget(toolbar)
qfigWidget.setLayout(plotLayout)
frame.toolbars[fig] = toolbar
frame.plots.append(axes)
canvas.setMinimumSize(canvas.size())
frame.bind_to_onclick_event(fig)
layout_contents[0].addWidget(qfigWidget)
frame.show()
sys.exit(app.exec_())
示例6: HistogramDialog
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import setMinimumSize [as 别名]
class HistogramDialog(QDialog, FORM_CLASS):
signalAskCloseWindow = pyqtSignal(int, name='signalAskCloseWindow')
def __init__(self, parent=None):
"""Constructor."""
QDialog.__init__(self, parent)
self.setupUi(self)
# Connect slot.
self.button_box.button(QDialogButtonBox.Ok).clicked.connect(
self.draw_plot)
self.button_box.button(QDialogButtonBox.Cancel).clicked.connect(
self.hide)
self.button_box.button(QDialogButtonBox.Cancel).clicked.connect(
self.signalAskCloseWindow.emit)
# Setup the graph.
self.figure = Figure()
self.ax = self.figure.add_subplot(1, 1, 1)
self.canvas = FigureCanvas(self.figure)
self.canvas.setMinimumSize(QSize(300, 0))
self.toolbar = CustomNavigationToolbar(self.canvas, self)
self.layout_plot.addWidget(self.toolbar)
self.layout_plot.addWidget(self.canvas)
def draw_plot(self):
"""Function to draw the plot and display it in the canvas."""
index = self.cbx_layer.currentIndex()
layer = self.cbx_layer.itemData(index)
render = layer.rendererV2()
for ran in render.ranges():
print "%f - %f: %s %s" % (
ran.lowerValue(),
ran.upperValue(),
ran.label(),
str(ran.symbol())
)
bar_list = self.ax.bar([1, 2, 3, 4], [1, 2, 3, 4])
bar_list[0].set_color('r')
bar_list[1].set_color('g')
bar_list[2].set_color('b')
self.canvas.draw()
示例7: __init__
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import setMinimumSize [as 别名]
def __init__(self, parent=None):
super(ExperimentResultWidget, self).__init__()
self.tab = QtGui.QTabWidget()
# Figure 1
figure = plt.figure()
canvas = FigureCanvas(figure)
canvas.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Expanding)
canvas.setMinimumSize(50, 50)
toolbar = NavigationToolbar(canvas, self)
toolbar.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)
widget = QtGui.QWidget()
layout = QtGui.QVBoxLayout()
layout.addWidget(canvas)
layout.addWidget(toolbar)
widget.setLayout(layout)
self.tab.addTab(widget, 'Results')
self.plot = figure
# Tab 1
self.trackCountsTable = QtGui.QTableWidget()
self.tab.addTab(self.trackCountsTable, 'Track Counts')
# Tab 2
self.networkOverviewTable = QtGui.QTableWidget()
self.tab.addTab(self.networkOverviewTable, 'Network Overview')
# Tab 3
self.trackTerminationTable = QtGui.QTableWidget()
self.trackInitiationTable = QtGui.QTableWidget()
widget = QtGui.QWidget()
layout = QtGui.QVBoxLayout()
layout.addWidget(self.trackTerminationTable)
layout.addWidget(self.trackInitiationTable)
widget.setLayout(layout)
self.tab.addTab(widget, 'Track Fragmentation')
layout = QtGui.QVBoxLayout()
layout.addWidget(self.tab)
self.setLayout(layout)
示例8: __init__
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import setMinimumSize [as 别名]
def __init__(self, scrollAreaWidgetContents):
QtGui.QWidget.__init__(self)
self.setParent(scrollAreaWidgetContents)
canvas = FigureCanvas(Figure((3.0, 2.0), dpi=100))
canvas.setParent(self)
toolbar = myNavigationToolbar(canvas, self)
toolbar.disableButtons()
temporal_toolbar = temporalNavigationToolbar(canvas, self)
mainImage = QtGui.QLabel(self)
mainImage.setText(_fromUtf8(""))
mainImage.setPixmap(QtGui.QPixmap(_fromUtf8(":/newPrefix/images/fromHelyx/emptyFigure.png")))
mainImage.setObjectName(_fromUtf8("mainImage"))
plotLayout = QtGui.QVBoxLayout()
plotLayout.addWidget(temporal_toolbar)
plotLayout.addWidget(mainImage)
plotLayout.addWidget(toolbar)
self.setLayout(plotLayout)
canvas.setMinimumSize(canvas.size())
示例9: SimpleSlicerQWidget
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import setMinimumSize [as 别名]
class SimpleSlicerQWidget(QtGui.QWidget):
"""
QT wrapper for matplotlib
"""
def __init__(self, parent=None):
"""
setup GUI
"""
self.dataset = None
self.ellipse_stack = None
self.active_layer = 0
QtGui.QWidget.__init__(self, parent)
self.my_layout = QtGui.QVBoxLayout(self)
#self.my_layout.setContentsMargin(0)
self.my_layout.setSpacing(0)
# set up matplotlib
self.dpi = 100
self.fig = Figure((6.0, 6.0), dpi=self.dpi)
self.canvas = FigureCanvas(self.fig)
self.canvas.setMinimumSize(800, 400)
#self.canvas.setParent(self)
self.my_layout.addWidget(self.canvas)
self.axes = self.fig.add_subplot(121)
self.axes_green = self.fig.add_subplot(122)
self.cax = None
#slider
self.sld = QtGui.QSlider(QtCore.Qt.Horizontal, self)
self.sld.setFocusPolicy(QtCore.Qt.NoFocus)
self.sld.setMinimum(0)
#self.sld.setGeometry(30, 40, 100, 30)
#sld.valueChanged[int].connect(self.changeValue)
self.my_layout.addWidget(self.sld)
self.connect(self.sld, QtCore.SIGNAL('valueChanged(int)'), self.update_active_layer)
def update_dataset(self, dataset):
"""
update plot
"""
self.dataset = dataset
new_max = self.dataset.volume.shape[2] - 1
self.sld.setMaximum(new_max)
self.update_plot()
def update_active_layer(self, idx_z):
"""
update active layer
"""
self.active_layer = idx_z
self.update_plot()
def update_plot(self):
"""
plotting routine
"""
channel1 = self.dataset.volume[:,:,self.active_layer].T
channel2 = self.dataset.green_channel[:,:,self.active_layer].T
self.axes.clear()
self.axes_green.clear()
self.axes.imshow(channel1, interpolation="nearest")
self.axes_green.imshow(channel2, interpolation="nearest", cmap=cm.Greys_r)
if self.dataset.stack:
n = 50
z = int(self.active_layer)
# check if ellipse is available for layer
if self.dataset.stack.has_key(z):
e = self.dataset.stack[z]
dat = e.sample_equidistant(n)
self.axes.plot(dat[0], dat[1], "b-", scalex=False, scaley=False)
self.axes_green.plot(dat[0], dat[1], "b-", scalex=False, scaley=False)
offset = self.dataset.radius_offset
# plot manual offset in red
if offset != 0:
e_off = copy.copy(e)
e_off.rx += offset
#.........这里部分代码省略.........
示例10: Window
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import setMinimumSize [as 别名]
class Window(QtGui.QWidget):
def __init__(self, parent=None):
super(Window, self).__init__(parent)
self.setWindowTitle('OpenWave-2KE V%s'%__version__)
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap("openwave.ico"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.setWindowIcon(icon)
#Waveform area.
self.figure = plt.figure()
self.figure.set_facecolor('white')
self.canvas = FigureCanvas(self.figure)
self.canvas.setMinimumSize(800, 400)
self.toolbar = NavigationToolbar(self.canvas, self)
self.toolbar.hide()
#Zoom In/out and Capture Buttons
self.zoomBtn = QtGui.QPushButton('Zoom')
self.zoomBtn.setFixedSize(100, 30)
self.zoomBtn.clicked.connect(self.toolbar.zoom)
self.panBtn = QtGui.QPushButton('Pan')
self.panBtn.setFixedSize(100, 30)
self.panBtn.clicked.connect(self.toolbar.pan)
self.homeBtn = QtGui.QPushButton('Home')
self.homeBtn.setFixedSize(100, 30)
self.homeBtn.clicked.connect(self.toolbar.home)
self.captureBtn = QtGui.QPushButton('Capture')
self.captureBtn.setFixedSize(100, 50)
self.captureBtn.clicked.connect(self.captureAction)
if(dso.connection_status==0):
self.captureBtn.setEnabled(False)
#Type: Raw Data/Image
self.typeBtn = QtGui.QPushButton('Raw Data')
self.typeBtn.setToolTip("Switch to get raw data or image from DSO.")
self.typeBtn.setFixedSize(120, 50)
self.typeFlag=True #Initial state -> Get raw data
self.typeBtn.setCheckable(True)
self.typeBtn.setChecked(True)
self.typeBtn.clicked.connect(self.typeAction)
#Channel Selection.
self.ch1checkBox = QtGui.QCheckBox('CH1')
self.ch1checkBox.setFixedSize(60, 30)
self.ch2checkBox = QtGui.QCheckBox('CH2')
self.ch2checkBox.setFixedSize(60, 30)
if(dso.chnum==4):
self.ch3checkBox = QtGui.QCheckBox('CH3')
self.ch3checkBox.setFixedSize(60, 30)
self.ch4checkBox = QtGui.QCheckBox('CH4')
self.ch4checkBox.setFixedSize(60, 30)
#Set channel selection layout.
self.selectLayout = QtGui.QHBoxLayout()
self.selectLayout.addWidget(self.ch1checkBox)
self.selectLayout.addWidget(self.ch2checkBox)
if(dso.chnum==4):
self.selectLayout2 = QtGui.QHBoxLayout()
self.selectLayout2.addWidget(self.ch3checkBox)
self.selectLayout2.addWidget(self.ch4checkBox)
self.typeLayout = QtGui.QHBoxLayout()
self.typeLayout.addWidget(self.typeBtn)
self.typeLayout.addLayout(self.selectLayout)
if(dso.chnum==4):
self.typeLayout.addLayout(self.selectLayout2)
#Save/Load/Quit button
self.saveBtn = QtGui.QPushButton('Save')
self.saveBtn.setFixedSize(100, 50)
self.saveMenu = QtGui.QMenu(self)
self.csvAction = self.saveMenu.addAction("&As CSV File")
self.pictAction = self.saveMenu.addAction("&As PNG File")
self.saveBtn.setMenu(self.saveMenu)
self.saveBtn.setToolTip("Save waveform to CSV file or PNG file.")
self.connect(self.csvAction, QtCore.SIGNAL("triggered()"), self.saveCsvAction)
self.connect(self.pictAction, QtCore.SIGNAL("triggered()"), self.savePngAction)
self.loadBtn = QtGui.QPushButton('Load')
self.loadBtn.setToolTip("Load CHx's raw data from file(*.csv, *.lsf).")
self.loadBtn.setFixedSize(100, 50)
self.loadBtn.clicked.connect(self.loadAction)
self.quitBtn = QtGui.QPushButton('Quit')
self.quitBtn.setFixedSize(100, 50)
self.quitBtn.clicked.connect(self.quitAction)
# set the layout
self.waveLayout = QtGui.QHBoxLayout()
self.waveLayout.addWidget(self.canvas)
self.wave_box=QtGui.QVBoxLayout()
self.wave_box.addLayout(self.waveLayout)
#.........这里部分代码省略.........
示例11: WaldoProcessPage
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import setMinimumSize [as 别名]
class WaldoProcessPage(QtGui.QWizardPage):
SHOWING_NOTHING = 0
SHOWING_IMAGE = 1
SHOWING_REPORT = 2
def __init__(self, data, parent=None):
super(WaldoProcessPage, self).__init__(parent)
self.data = data
self.waldoProcessCompleted = False
self.setTitle("Running WALDO")
self.image_figure = plt.figure()
self.image_canvas = FigureCanvas(self.image_figure)
self.image_canvas.setMinimumSize(50, 50)
self.image_canvas.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Expanding)
self.ax_image = self.image_figure.add_subplot(111)
self.ax_image.axis('off')
self.report_figure = plt.figure()
self.report_canvas = FigureCanvas(self.report_figure)
self.report_canvas.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Expanding)
self.report_canvas.setMinimumSize(50, 50)
self.ax_report = self.report_figure.add_subplot(111)
self.main_layout = QtGui.QHBoxLayout()
self.showing_status = WaldoProcessPage.SHOWING_NOTHING
layout = QtGui.QVBoxLayout()
layout.addLayout(self.main_layout)
self.setLayout(layout)
def initializePage(self):
self.data.single_result_message = (WaldoBatchRunResult.CACHED, None)
self.waldoProcessCompleted = False
QTimer.singleShot(0, self.show_dialog)
def show_dialog(self):
dlg = WaldoProcessDialog(self.data.experiment,
self.waldoProcess, self.show_image, self.show_report, self.finished, self)
dlg.setModal(True)
dlg.exec_()
def _set_image(self, image):
if self.showing_status == WaldoProcessPage.SHOWING_REPORT:
self.report_canvas.setParent(None)
self.showing_status = WaldoProcessPage.SHOWING_NOTHING
if self.showing_status == WaldoProcessPage.SHOWING_NOTHING:
self.main_layout.addWidget(self.image_canvas)
self.showing_status = WaldoProcessPage.SHOWING_IMAGE
self.ax_image.clear()
self.ax_image.imshow(image, cmap=plt.cm.gray, interpolation='nearest')
self.ax_image.axis('off')
def _set_report(self, report):
# print("HELIO", report.head())
if self.showing_status == WaldoProcessPage.SHOWING_IMAGE:
self.image_canvas.setParent(None)
self.showing_status = WaldoProcessPage.SHOWING_NOTHING
if self.showing_status == WaldoProcessPage.SHOWING_NOTHING:
self.main_layout.addWidget(self.report_canvas)
self.showing_status = WaldoProcessPage.SHOWING_REPORT
d = report[['phase', 'connected-nodes', 'total-nodes']][::-1]
d = d.drop_duplicates('phase', take_last=False)
d = d.set_index('phase')
self.ax_report.clear()
d.plot(ax=self.ax_report, kind='barh')
self.ax_report.set_xlabel('Number of Track Fragments', size=15)
self.ax_report.legend(frameon=False, loc=(1.01, 0.7), fontsize=15)
self.ax_report.set_ylabel('phase', size=15)
self.report_figure.tight_layout()
self.report_figure.subplots_adjust(right=0.6)
self.report_figure.canvas.draw()
# plt.yticks(fontsize=12)
# plt.xticks(fontsize=12)
def waldoProcess(self, callback):
try:
times, impaths = zip(*sorted(self.data.experiment.image_files.items()))
impaths = [str(s) for s in impaths]
self.last_image_index = 0
def callback_with_image(x):
if len(impaths) == 0:
return
index = int(x * len(impaths))
if index > len(impaths) - 1:
index = len(impaths) - 1
if index - self.last_image_index < 1:
return
self.last_image_index = index
im = mpimg.imread(impaths[index])
#.........这里部分代码省略.........
示例12: FilterDesignDialog
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import setMinimumSize [as 别名]
class FilterDesignDialog(QtGui.QDialog):
"""A dialog to apply Takanami's AR picking method to a selected piece of a
seismic signal.
Attributes:
document: Current opened document containing a seismic record.
seismic_event: A seismic event to be refined by using Takanami method.
If no event is provided, then a new seismic event will be created
by using the estimated arrival time after clicking on 'Accept'
"""
def __init__(self, stream, trace_list=None, parent=None):
super(FilterDesignDialog, self).__init__(parent)
# Calc max. frequency
traces = stream.traces if not trace_list else trace_list
self.max_freq = max([trace.fs for trace in traces])
self._init_ui()
self.load_settings()
# Initial draw
w, h_db, angles = self._retrieve_filter_plot_data()
self._module_data = self.module_axes.plot(w, h_db, 'b')[0]
self._phase_data = self.phase_axes.plot(w, angles, 'g')[0]
self.module_axes.set_ylim([-60,10])
self.phase_axes.set_ylim([min(angles), max(angles)])
self.canvas.draw_idle()
self.start_point_spinbox.valueChanged.connect(self.on_freq_min_changed)
self.end_point_spinbox.valueChanged.connect(self.on_freq_max_changed)
self.start_point_spinbox.valueChanged.connect(self._draw_filter_response)
self.end_point_spinbox.valueChanged.connect(self._draw_filter_response)
self.number_coefficient_spinbox.valueChanged.connect(self._draw_filter_response)
self.zeroPhaseCheckBox.toggled.connect(self._draw_filter_response)
self.button_box.accepted.connect(self.accept)
self.button_box.rejected.connect(self.reject)
self.button_box.clicked.connect(self.on_click)
def _init_ui(self):
self.setWindowTitle("Filter Design (Butterworth-Bandpass Filter)")
self.fig, _ = plt.subplots(1, 1, sharex=True)
# Set up filter axes
self.module_axes = self.fig.axes[0]
self.phase_axes = self.module_axes.twinx()
self.module_axes.set_title('Digital filter frequency response (Butterworth-Bandpass filter)')
self.module_axes.set_xlabel('Frequency [Hz]')
self.module_axes.set_ylabel('Amplitude [dB]', color='b')
self.module_axes.axis('tight')
self.module_axes.grid(which='both', axis='both')
self.phase_axes.set_ylabel('Angle (radians)', color='g')
self.canvas = FigureCanvas(self.fig)
self.canvas.setMinimumSize(self.canvas.size())
self.canvas.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Policy.Expanding,
QtGui.QSizePolicy.Policy.Expanding))
self.toolBarNavigation = navigationtoolbar.NavigationToolBar(self.canvas, self)
self.group_box = QtGui.QGroupBox(self)
self.group_box2 = QtGui.QGroupBox(self)
self.group_box3 = QtGui.QGroupBox(self)
self.group_box4 = QtGui.QGroupBox(self)
self.group_box.setTitle("")
self.group_box2.setTitle("")
self.group_box3.setTitle("Parameters")
self.start_point_label = QtGui.QLabel("Lower cutoff frequency (Hz): ")
self.start_point_label.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Policy.Maximum,
QtGui.QSizePolicy.Policy.Preferred))
self.start_point_spinbox = QtGui.QDoubleSpinBox(self.group_box)
self.start_point_spinbox.setMinimum(1.0)
self.start_point_spinbox.setSingleStep(1.00)
self.start_point_spinbox.setAccelerated(True)
self.start_point_spinbox.setMaximum(self.max_freq * 0.5)
self.end_point_label = QtGui.QLabel("Higher cutoff frequency (Hz):")
self.end_point_label.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Policy.Maximum,
QtGui.QSizePolicy.Policy.Preferred))
self.end_point_spinbox = QtGui.QDoubleSpinBox(self.group_box4)
self.end_point_spinbox.setMinimum(1.0)
self.end_point_spinbox.setSingleStep(1.00)
self.end_point_spinbox.setAccelerated(True)
self.end_point_spinbox.setMaximum(self.max_freq * 0.5)
self.end_point_spinbox.setValue(5.0)
#######################################################################
self.number_coefficient_label = QtGui.QLabel("Order: ")
self.number_coefficient_label2 = QtGui.QLabel("")
self.number_coefficient_label.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Policy.Maximum,
QtGui.QSizePolicy.Policy.Preferred))
self.number_coefficient_label2.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Policy.Maximum,
QtGui.QSizePolicy.Policy.Preferred))
self.number_coefficient_spinbox = QtGui.QSpinBox(self.group_box3)
self.number_coefficient_spinbox.adjustSize()
self.number_coefficient_spinbox.setMinimum(1)
self.number_coefficient_spinbox.setSingleStep(1)
self.number_coefficient_spinbox.setAccelerated(True)
self.zeroPhaseCheckBox = QtGui.QCheckBox("Zero phase filtering", self.group_box2)
self.zeroPhaseCheckBox.setChecked(True)
#######################################################################
self.group_box_layout = QtGui.QHBoxLayout(self.group_box)
self.group_box_layout.setContentsMargins(9, 9, 9, 9)
#.........这里部分代码省略.........
示例13: Window
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import setMinimumSize [as 别名]
class Window(QtGui.QWidget):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.shot = None #opened shot
self.folder_name = '' #folder to search for shots
self.current_num = 0 #current diagram
self.currently_selected = None #selected point plot
self.selected_points = OrderedSet() #point to be added
self.current_point = None #plot of current point
self.overall_selected = None #points added to selected list
#super(Window, self).__init__(parent)
# a figure instance to plot on
self.figure = plt.figure()
# this is the Canvas Widget that displays the `figure`
# it takes the `figure` instance as a parameter to __init__
self.canvas = FigureCanvas(self.figure)
self.canvas.setParent(parent)
self.canvas.setFocusPolicy(QtCore.Qt.StrongFocus)
self.canvas.setFocus()
self.canvas.setMinimumSize(500, 0)
self.canvas.mpl_connect('pick_event', self.on_pick)
self.canvas.mpl_connect('motion_notify_event', self.on_move)
self.canvas.hide()
# this is the Navigation widget
# it takes the Canvas widget and a pa rent
self.toolbar = NavigationToolbar(self.canvas, self)
self.toolbar.hide()
# Show files widget
self.files = QtGui.QListWidget()
self.files.itemDoubleClicked.connect(self.select_file)
self.files.setMaximumSize(200, 100000)
self.files.setMinimumSize(100, 0)
self.files.hide()
# Show selected points
self.points = ThumbListWidget(self)
#self.points.itemDoubleClicked.connect(self.unselect_point)
self.points.itemClicked.connect(self.points_clicked)
self.points.itemDoubleClicked.connect(self.points_doubleclicked)
self.points.setMaximumSize(200, 100000)
self.points.setMinimumSize(100, 0)
self.points.hide()
#Show diagram widget
self.diagrams = QtGui.QListWidget()
self.diagrams.itemClicked.connect(self.select_item)
self.diagrams.setMaximumSize(250, 100000)
self.diagrams.setMinimumSize(190, 0)
self.diagrams.hide()
#save result button
self.save_button = QtGui.QPushButton('Add time point', self)
self.save_button.clicked.connect(self.add_time)
self.save_button.hide()
#filter menu
self.filters_button = QtGui.QPushButton('Manage filters', self)
self.filters_button.clicked.connect(self.show_filters)
self.filters_button.hide()
self.filters = OrderedDict
self.read_filters()
#diagramms
self.bottom_layout = QtGui.QGridLayout()
self.diagrams_figure = plt.figure()
self.diagrams_canvas = FigureCanvas(self.diagrams_figure)
self.diagrams_canvas.setParent(parent)
self.diagrams_canvas.setMinimumSize(250, 250)
self.diagrams_canvas.setMaximumSize(500, 500)
self.diagrams_toolbar = NavigationToolbar(self.diagrams_canvas, self)
self.diagrams_toolbar.setMaximumWidth(250)
self.diagrams_ax = self.diagrams_figure.add_subplot(111)
self.diagrams_ax.set_ylim(ymin=0)
self.diagrams_ax.set_xlim(xmin=0)
self.diagrams_canvas.draw()
self.enlargre_button = QtGui.QPushButton('Enlarge diagram', self)
self.enlargre_button.clicked.connect(self.enlarge_diagram)
self.bottom_layout.addWidget(self.diagrams_toolbar, 0, 2)
self.bottom_layout.addWidget(self.diagrams_canvas, 1, 2, QtCore.Qt.AlignRight)
self.bottom_layout.addWidget(self.enlargre_button, 0, 1)
# set the layout
self.layout = QtGui.QGridLayout()
self.layout.addWidget(self.filters_button, 0, 1)
self.layout.addWidget(self.toolbar, 0, 2)
self.layout.addWidget(self.canvas, 1, 2)
self.layout.addWidget(self.diagrams, 1, 1)
self.layout.addWidget(self.files, 1, 0)
self.layout.addWidget(self.points, 1, 3)
self.layout.addWidget(self.save_button, 0, 3)
self.layout.addLayout(self.bottom_layout, 2, 2)
self.setLayout(self.layout)
#.........这里部分代码省略.........
示例14: Amoeba_Line_Graph
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import setMinimumSize [as 别名]
class Amoeba_Line_Graph():
def __init__(self):
"""
This class is for the plot on each of the parameter UIs.
"""
#Generate plot
x = []
y = []
self.fig = Figure(figsize=(8,4),dpi=72, facecolor=(1,1,1), edgecolor=(0,0,0))
self.sub_plot = self.fig.add_subplot(111)
self.sub_plot.xaxis_date()
if AMOEBA_LINE_GRAPH_DEBUG:
print "X = "
print x
print "Y = "
print y
print "Create "
print self.sub_plot.plot
self.sub_plot.plot(y,x,'b')
self.sub_plot.set_xlabel('Time')
self.fig.autofmt_xdate()
#Create canvas for the plot
self.canvas = FigureCanvas(self.fig)
self.canvas.setMinimumSize(self.canvas.size())
def update(self,datay,datax):
"""
This method updates the plot with the input data.
:param datay: Y axis of the points to plot.
:param datax: X axis of the points to plot.
"""
if AMOEBA_LINE_GRAPH_DEBUG:
print "Update sub plot"
print "X = "
print datax
print "Y = "
print datay
print "Update "
print self.sub_plot.plot
# Clear the graph.
self.clear_graph()
self.sub_plot.plot(datax,datay,'b')
self.sub_plot.set_visible(True)
self.sub_plot.autoscale(True,"both")
self.canvas.draw()
def retrieve_graph(self):
"""
This method returns the plot's widget.
:return:
"""
return self.canvas
def clear_graph(self):
"""
This method clears the graph.
"""
y = []
x = []
self.sub_plot.clear()
self.sub_plot.set_visible(True)
self.sub_plot.autoscale(True,"both",False)
self.sub_plot.plot(y,x,'b')
self.canvas.draw()
示例15: HistogramQWidget
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import setMinimumSize [as 别名]
class HistogramQWidget(QtGui.QWidget):
"""
QT wrapper for matplotlib
"""
def __init__(self, parent=None):
"""
setup GUI
"""
self.data = None
self.value = 0
QtGui.QWidget.__init__(self, parent)
self.my_layout = QtGui.QGridLayout(self)
#self.my_layout.setMargin(0)
self.my_layout.setSpacing(10)
# set up matplotlib
self.dpi = 100
self.fig = Figure((6.0, 6.0), dpi=self.dpi)
self.canvas = FigureCanvas(self.fig)
self.canvas.setMinimumSize(300, 100)
self.canvas.mpl_connect('button_press_event', self.on_click)
#self.canvas.setParent(self)
self.my_layout.addWidget(self.canvas, 0, 0, 1, 2)
self.axes = self.fig.add_subplot(111)
self.cax = None
# add spin box
self.spin_label = QtGui.QLabel(self)
self.spin_label.setText('Value:')
self.my_layout.addWidget(self.spin_label, 1, 0)
self.spin = QtGui.QDoubleSpinBox(self)
self.spin.setMinimum(0.0)
self.spin.setMaximum(1000.0)
#self.spin.setFocusPolicy(QtCore.Qt.NoFocus)
self.spin.setSingleStep(10)
self.spin.setKeyboardTracking(False)
self.spin.setReadOnly(False)
self.my_layout.addWidget(self.spin, 1, 1)
# connect signals
self.connect(self.spin, QtCore.SIGNAL('valueChanged(double)'), self.update_value)
def on_click(self, event):
"""
process click from matplotlib
"""
print 'button=%d, x=%d, y=%d, xdata=%f, ydata=%f'%(event.button, event.x, event.y, event.xdata, event.ydata)
self.update_value(float(event.xdata))
def update_value(self, v):
"""
update plot
"""
self.value = v
self.spin.setValue(self.value)
self.update_plot()
self.emit(QtCore.SIGNAL('thresholdChanged(double)'), self.value)
def update_dataset(self, dataset):
"""
wrapper for update value
"""
#TODO this can go in subclass
self.value = dataset.threshold
self.data = dataset.red_channel.flatten()
self.update_plot()
self.spin.blockSignals(True)
self.spin.setValue(self.value)
self.spin.blockSignals(False)
def update_plot(self):
"""
plotting routine
"""
print "updating histogram plot"
self.axes.clear()
self.axes.hist(self.data, bins=100, range=(min(self.data), max(self.data)))
self.axes.axvline(x=self.value, linewidth=1, color='r')
self.canvas.draw()