本文整理汇总了Python中matplotlib.backends.backend_qt5agg.FigureCanvasQTAgg.setMinimumHeight方法的典型用法代码示例。如果您正苦于以下问题:Python FigureCanvasQTAgg.setMinimumHeight方法的具体用法?Python FigureCanvasQTAgg.setMinimumHeight怎么用?Python FigureCanvasQTAgg.setMinimumHeight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.backends.backend_qt5agg.FigureCanvasQTAgg
的用法示例。
在下文中一共展示了FigureCanvasQTAgg.setMinimumHeight方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Window
# 需要导入模块: from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt5agg.FigureCanvasQTAgg import setMinimumHeight [as 别名]
#.........这里部分代码省略.........
self.molwtLabel = QLabel("<b>Mol. Weight:</b> Unknown")
self.structure.setText("No Structure Available")
self.structure.setAlignment(Qt.AlignCenter)
else:
self.smilesLabel = QLabel("<b>SMILES:</b> Unknown")
self.molformulaLabel = QLabel("<b>Mol. Formula:</b> Unknown")
self.molwtLabel = QLabel("<b>Mol. Weight:</b> Unknown")
self.structure.setText("No Structure Available")
self.structure.setAlignment(Qt.AlignCenter)
self.editinfoButton = QPushButton('Edit Compound Info')
self.editinfoButton.setToolTip("Opens a window to edit compound information") # TODO: Set tooltip
self.restoreinfoButton = QPushButton('Restore Compound Info')
self.restoreinfoButton.setToolTip("Resets compound information to original imported values") # TODO: Set tooltip
self.savestructureButton = QPushButton('Save Structure Image')
self.savestructureButton.setToolTip("Tooltip") # TODO: Set tooltip
def initSpectrum(self):
# Compound Spectrum Tab
matplotlib.projections.register_projection(My_Axes)
self.scale = 1.05
self.show_ignored = True
self.show_ignored_peaks = True
self.compoundtab2 = QWidget()
self.compoundtab2.setStyleSheet("QWidget{background-color: white;}")
self.fig = plt.gcf()
self.fig.patch.set_facecolor('white')
self.canvas = FigureCanvas(self.fig)
self.canvas.setParent(self)
self.canvas.setFocusPolicy(Qt.StrongFocus)
self.canvas.setFocus()
self.canvas.setMinimumHeight(100)
self.canvas.setMinimumWidth(100)
self.mpl_toolbar = NavigationToolbar2(self.canvas, self)
self.mpl_toolbar.hide()
self.mpl_toolbar.pan()
self.canvas.mpl_connect('scroll_event', self.zooming)
ins = "Left-click+drag to pan x-axis / Right-click+drag to zoom x-axis / Scroll-wheel to change intensity scale"
self.instructionLabel = QLabel(ins)
self.instructionLabel.setStyleSheet('QLabel{qproperty-alignment: AlignCenter; font-size: 10px;}')
self.showignoredregionsCheckBox = QCheckBox("Show Ignored Regions")
self.showignoredregionsCheckBox.setToolTip("Shows the ranges set by the solvent/buffer ignore regions, if any.")
self.showignoredregionsCheckBox.setLayoutDirection(Qt.RightToLeft)
self.showignoredregionsCheckBox.setChecked(True)
self.showignoredpeaksCheckBox = QCheckBox("Show Ignored Peaks")
self.showignoredpeaksCheckBox.setToolTip("Shows any compound peaks that are in the solvent/buffer ignore regions, if any.\n"
"These peaks are ignored and are not evaluated during mixing.")
self.showignoredpeaksCheckBox.setLayoutDirection(Qt.RightToLeft)
self.showignoredpeaksCheckBox.setChecked(True)
self.resetviewButton = QPushButton("Reset View")
self.resetviewButton.setToolTip("Resets the spectrum to the default view.")
self.savespectrumButton = QPushButton("Save Spectrum")
self.savespectrumButton.setToolTip("Saves the image in the spectrum window.")
def initPeaklistTable(self):
# Compound Peaklist Tab
self.compoundtab3 = QWidget()
self.compoundtab3.setStyleSheet("QWidget{background-color: white;}")
self.peakTable = QTableWidget(0, 4, self)
# self.peakTable.setMinimumWidth(400)
self.peakTable.setSelectionMode(QAbstractItemView.NoSelection)
self.peakTable.setSelectionBehavior(QAbstractItemView.SelectRows)
self.peakTable.setSelectionMode(QAbstractItemView.SingleSelection)
self.peakTable.setSortingEnabled(True)
示例2: Window
# 需要导入模块: from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt5agg.FigureCanvasQTAgg import setMinimumHeight [as 别名]
class Window(QDialog):
def __init__(self, params_object, library_object, group, parent=None):
QDialog.__init__(self, parent)
self.params = params_object
self.library = library_object
self.group = group
matplotlib.projections.register_projection(My_Axes)
self.region_colors = {0:'gray', 1:'red', 2:'green', 3:'orange', 4:'teal', 5:'pink',
6:'cyan', 7:'magenta', 8:'gold'}
if self.group == 'ALL':
self.plural_group = "s"
else:
self.plural_group = ""
self.setWindowTitle("NMRmix: Peaks Histogram for %s Group%s" % (self.group, self.plural_group))
self.scale = 1.05
self.setAttribute(Qt.WA_DeleteOnClose, True)
self.createMainFrame()
def createMainFrame(self):
self.fig = plt.gcf()
self.fig.patch.set_facecolor('white')
self.canvas = FigureCanvas(self.fig)
self.canvas.setParent(self)
self.canvas.setFocusPolicy(Qt.StrongFocus)
self.canvas.setFocus()
self.canvas.setMinimumHeight(100)
self.canvas.setMinimumWidth(100)
self.mpl_toolbar = NavigationToolbar2(self.canvas, self)
self.mpl_toolbar.hide()
self.mpl_toolbar.pan()
self.canvas.mpl_connect('scroll_event', self.zooming)
ins = "Left-click+drag to pan x-axis / Right-click+drag to zoom x-axis"
self.instructionLabel = QLabel(ins)
self.instructionLabel.setStyleSheet('QLabel{qproperty-alignment: AlignCenter; font-size: 12px;}')
self.showignoredregionsCheckBox = QCheckBox("Show Ignored Regions")
self.showignoredregionsCheckBox.setChecked(True)
self.showignoredregionsCheckBox.setToolTip("Tooltip") # TODO: Tooltip
self.showignoredregionsCheckBox.stateChanged.connect(self.handleIgnored)
self.closeButton = QPushButton("Close")
self.closeButton.setStyleSheet("QPushButton{color: red; font-weight: bold;}")
self.closeButton.clicked.connect(self.closeEvent)
self.saveButton = QPushButton("Save")
self.saveButton.setStyleSheet("QPushButton{color: green; font-weight: bold;}")
self.saveButton.clicked.connect(self.saveResults)
self.resetButton = QPushButton("Reset")
self.resetButton.setStyleSheet("QPushButton{color: blue; font-weight: bold;}")
self.resetButton.clicked.connect(self.resetGraph)
self.calculateAllHistogram()
self.calculateIntenseHistogram()
self.drawIgnoredRegions()
winLayout = QVBoxLayout(self)
winLayout.addWidget(self.canvas)
winLayout.addWidget(self.instructionLabel)
winLayout.addWidget(self.showignoredregionsCheckBox)
buttonLayout = QHBoxLayout()
buttonLayout.addWidget(self.closeButton)
buttonLayout.addWidget(self.resetButton)
buttonLayout.addWidget(self.saveButton)
winLayout.addLayout(buttonLayout)
winLayout.setAlignment(self.showignoredregionsCheckBox, Qt.AlignCenter)
self.fig.tight_layout(pad=3)
self.canvas.draw()
def calculateAllHistogram(self):
self.ax1 = self.fig.add_subplot(211, projection="My_Axes")
self.ax1.set_title("Peaks Histogram for %s Group%s" % (self.group, self.plural_group), fontweight='bold')
self.ax1.set_xlabel("Chemical Shift (ppm)", fontweight='bold')
self.ax1.set_ylabel("Number of Peaks", fontweight='bold')
data = list(self.library.stats[self.group]['Peaklist'])
y, binEdges = np.histogram(data, bins=np.arange(-1, 12, 0.02))
bincenters = 0.5 * (binEdges[1:] + binEdges[:-1])
self.ax1.set_xlim(self.params.shift_range[self.params.nuclei])
self.upper_ylim_all = max(y)+(math.ceil(max(y)*0.05))
self.ax1.set_ylim([0, self.upper_ylim_all])
self.ax1.plot(bincenters, y, '-', color='blue')
def calculateIntenseHistogram(self):
self.ax2 = self.fig.add_subplot(212, sharex=self.ax1, projection="My_Axes")
self.ax2.set_title("Intense Peaks Histogram for %s Group%s" % (self.group, self.plural_group),
fontweight='bold')
self.ax2.set_xlabel("Chemical Shift (ppm)", fontweight='bold')
self.ax2.set_ylabel("Number of Peaks", fontweight='bold')
data = list(self.library.stats[self.group]['Intense Peaklist'])
y, binEdges = np.histogram(data, bins=np.arange(-1, 12, 0.02))
bincenters = 0.5 * (binEdges[1:] + binEdges[:-1])
self.ax2.set_xlim([12, -1])
self.upper_ylim_intense = max(y)+(math.ceil(max(y)*0.05))
self.ax2.set_ylim([0, self.upper_ylim_intense])
self.ax2.plot(bincenters, y, '-', color='purple')
def resetGraph(self):
self.mpl_toolbar.home()
def drawIgnoredRegions(self):
groups = ['ALL']
if self.group != 'ALL':
groups.append(self.group)
for region in self.library.ignored_regions:
#.........这里部分代码省略.........
示例3: Window
# 需要导入模块: from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt5agg.FigureCanvasQTAgg import setMinimumHeight [as 别名]
class Window(QDialog):
def __init__(self, params_object, library_object, group, parent=None):
QDialog.__init__(self, parent)
self.params = params_object
self.library = library_object
self.group = group
matplotlib.projections.register_projection(My_Axes)
self.region_colors = {0:'gray', 1:'red', 2:'green', 3:'orange', 4:'teal', 5:'pink',
6:'cyan', 7:'magenta', 8:'gold'}
if self.group == 'ALL':
self.plural_group = "s"
else:
self.plural_group = ""
self.setWindowTitle("NMRmix: Peak Aromaticity Histogram for %s Group%s" % (self.group, self.plural_group))
self.setAttribute(Qt.WA_DeleteOnClose, True)
self.scale = 1.05
self.mean = np.mean(self.library.stats[group]['Aromaticity'])
self.stdev = np.std(self.library.stats[group]['Aromaticity'])
self.median = np.median(self.library.stats[group]['Aromaticity'])
self.createMainFrame()
def createMainFrame(self):
self.fig = plt.gcf()
self.fig.patch.set_facecolor('white')
self.canvas = FigureCanvas(self.fig)
self.canvas.setParent(self)
self.canvas.setFocusPolicy(Qt.StrongFocus)
self.canvas.setFocus()
self.canvas.setMinimumHeight(100)
self.canvas.setMinimumWidth(100)
self.mpl_toolbar = NavigationToolbar2(self.canvas, self)
self.mpl_toolbar.hide()
# self.mpl_toolbar.pan()
self.canvas.mpl_connect('scroll_event', self.zooming)
ins = "Left-click+drag to pan x-axis / Right-click+drag to zoom x-axis"
self.instructionLabel = QLabel(ins)
self.instructionLabel.setStyleSheet('QLabel{qproperty-alignment: AlignCenter; font-size: 12px;}')
self.closeButton = QPushButton("Close")
self.closeButton.setStyleSheet("QPushButton{color: red; font-weight: bold;}")
self.closeButton.clicked.connect(self.closeEvent)
self.saveButton = QPushButton("Save")
self.saveButton.setStyleSheet("QPushButton{color: green; font-weight: bold;}")
self.saveButton.clicked.connect(self.saveResults)
self.resetButton = QPushButton("Reset")
self.resetButton.setStyleSheet("QPushButton{color: blue; font-weight: bold;}")
self.resetButton.clicked.connect(self.resetGraph)
self.calculateHistogram()
winLayout = QVBoxLayout(self)
winLayout.addWidget(self.canvas)
winLayout.addWidget(self.instructionLabel)
buttonLayout = QHBoxLayout()
buttonLayout.addWidget(self.closeButton)
buttonLayout.addWidget(self.resetButton)
buttonLayout.addWidget(self.saveButton)
winLayout.addLayout(buttonLayout)
self.fig.tight_layout(pad=3)
self.canvas.draw()
def calculateHistogram(self):
self.ax = self.fig.add_subplot(111, projection="My_Axes")
self.ax.set_title("Peak Aromaticity Histogram for %s Group%s" % (self.group, self.plural_group),
fontweight='bold')
self.ax.set_xlabel("Percentage of Aromatic Peaks (aromatic >= %0.3f ppm)" % self.params.aromatic_cutoff, fontweight='bold')
self.ax.set_ylabel("Number of Compounds", fontweight='bold')
data = list(self.library.stats[self.group]['Aromaticity'])
self.ax.hist(data, bins=range(0, 110, 10), color='red', alpha=0.75, rwidth=0.9)
self.ax.xaxis.set_ticks_position('none')
self.ax.yaxis.set_ticks_position('none')
self.ax.annotate("Mean: %.1f %%" % (self.mean), xy=(0.70, 0.82), xycoords='figure fraction',
horizontalalignment='left')
self.ax.annotate("Median: %.0f %%" % (self.median), xy=(0.70, 0.79), xycoords='figure fraction',
horizontalalignment='left')
def resetGraph(self):
self.mpl_toolbar.home()
def zooming(self, event):
cur_ylim = self.ax.get_ylim()
cur_yrange = (cur_ylim[1] - cur_ylim[0])
if event.button == 'up':
scale_factor = self.scale
elif event.button == 'down':
scale_factor = 1/self.scale
else:
scale_factor = 1
self.ax.set_ylim([0, (cur_yrange*scale_factor)])
self.canvas.draw()
def saveResults(self):
filename = "peakaromaticity.png"
filepath = os.path.join(self.params.work_dir, filename)
filestype = "static (*.png *.jpg *.svg)"
fileObj = QFileDialog.getSaveFileName(self, caption="Save Peak Stats Plot", directory=filepath, filter=filestype)
if fileObj[0]:
self.fig.set_size_inches(12, 8)
plt.savefig(fileObj[0], dpi=200)
def closeEvent(self, event=False):
#.........这里部分代码省略.........
示例4: __init__
# 需要导入模块: from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt5agg.FigureCanvasQTAgg import setMinimumHeight [as 别名]
class ScatterPlot:
def __init__(self, dataset):
"""
Initialize the matplotlib plot.
:param dataset: Dataset model.
"""
self.temporalData = dataset.temporalData
self.selectedSpecies = dataset.selectedSpecies
self.figure = Figure()
self.mplCanvas = FigureCanvasQTAgg(self.figure)
self.mplCanvas.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
self.mplCanvas.updateGeometry()
self.mplCanvas.setMinimumHeight(QDesktopWidget().availableGeometry().height() * 0.64)
self.mplCanvas.setStatusTip(
"Month ranges from 1 (inclusive) to 13 (exclusive). "
"January 1 is transformed into 1.00 and December 31 is transformed into 12.97."
)
self.minYear, self.maxYear = 1000000, 0
self.axes = self.figure.add_subplot(111)
self.axes.hold(False)
self.rebuild()
def rebuild(self):
"""
Rebuild the matplotlib plot.
:return: None.
"""
months, years, colors, sizes = [], [], [], []
for key, value in self.selectedSpecies.items():
for timestamp, amount in self.temporalData[key]:
month = timestamp.month + (timestamp.day - 1) / 31
year = timestamp.year
months.append(month)
years.append(year)
colors.append(value.color)
sizes.append(128 * (amount ** 0.5) + 128)
minYear, maxYear = self.getYearRange()
self.axes.scatter(months, years, c=colors, s=sizes, alpha=0.5, edgecolors="face")
self.axes.set_xlabel("Month")
self.axes.set_ylabel("Year")
self.axes.set_xticks(list(range(1, 14)))
self.axes.set_yticks(list(range(minYear - 1, maxYear + 2)))
self.axes.set_xlim(1, 13)
self.axes.set_ylim(minYear - 1, maxYear + 1)
self.axes.grid(True)
self.axes.ticklabel_format(useOffset=False)
self.figure.tight_layout()
self.mplCanvas.draw()
def getYearRange(self):
"""
Get the maximum and minimum year in the dataset.
:return: Tuple of (minimum year, maximum year).
"""
# Do not calculate if it has already been done.
if len(self.temporalData) and self.maxYear is 0:
years = [t[0].year for ts in self.temporalData.values() for t in ts]
minY, maxY = 1000000, 0
for year in years:
if year > maxY:
maxY = year
if year < minY:
minY = year
# Cache the results.
self.minYear, self.maxYear = minY, maxY
return self.minYear, self.maxYear
def resetCache(self):
"""
Reset the cached minimum year and maximum year
so that they could be recalculated next time.
:return: None.
"""
self.minYear, self.maxYear = 1000000, 0
示例5: Window
# 需要导入模块: from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt5agg.FigureCanvasQTAgg import setMinimumHeight [as 别名]
class Window(QDialog):
def __init__(self, params_object, library_object, compound_list, mixture_id, parent=None):
QDialog.__init__(self, parent)
matplotlib.projections.register_projection(My_Axes)
self.library = library_object
self.params = params_object
self.compounds = list(compound_list)
self.mixture_id = mixture_id
self.show_list = list(compound_list)
self.compound_colors_list = ['red', 'blue', 'green', 'orange', 'purple', 'teal', 'pink', 'gray',
'cyan', 'magenta', 'gold', 'brown', 'olive', 'yellow', 'maroon',
'darkseagreen', 'darksalmon', 'turquoise', 'khaki', 'crimson']
self.compound_colors = self.compound_colors_list * ((len(self.show_list) // 20) + 1)
self.scale = 1.05
self.show_rois = True
self.show_full_rois = False
self.show_ignored = False
self.show_ignored_peaks = False
self.show_positive_overlap = False
self.setWindowTitle("NMRmix: Simulated Spectra of Mixture %s" % self.mixture_id)
self.createMainFrame()
self.drawData()
def createMainFrame(self):
self.fig = plt.gcf()
self.fig.patch.set_facecolor('white')
self.fig.set_size_inches(12, 5)
self.canvas = FigureCanvas(self.fig)
self.canvas.setParent(self)
self.canvas.setFocusPolicy(Qt.StrongFocus)
self.canvas.setFocus()
self.canvas.setMinimumHeight(100)
self.canvas.setMinimumWidth(100)
self.mpl_toolbar = NavigationToolbar2(self.canvas, self)
self.mpl_toolbar.hide()
self.mpl_toolbar.pan()
self.canvas.mpl_connect('scroll_event', self.zooming)
self.showroisCheckBox = QCheckBox("Show Unoverlapped ROIs")
self.showroisCheckBox.setStyleSheet('QCheckBox{font-size: 12px;}')
self.showroisCheckBox.setToolTip("Shows the regions of interest around every non-overlapped peak.\n"
"Useful for visualizing the regions that should be monitored in this mixture.")
self.showroisCheckBox.setChecked(True)
self.showfullroisCheckBox = QCheckBox("Show Complete ROIs")
self.showfullroisCheckBox.setStyleSheet('QCheckBox{font-size: 12px;}')
self.showfullroisCheckBox.setToolTip("Shows the regions of interest around every peak regardless of whether\n"
"it is overlapped or not. Useful for visualizing the magnitude of overlaps.")
self.showignoredregionsCheckBox = QCheckBox("Show Ignored Regions")
self.showignoredregionsCheckBox.setStyleSheet('QCheckBox{font-size: 12px;}')
self.showignoredregionsCheckBox.setToolTip("Shows the ranges set by the solvent/buffer ignore regions, if any.")
self.showignoredpeaksCheckBox = QCheckBox("Show Ignored Peaks")
self.showignoredpeaksCheckBox.setStyleSheet('QCheckBox{font-size: 12px;}')
self.showignoredpeaksCheckBox.setToolTip("Shows any compound peaks that are in the solvent/buffer ignore regions, if any.\n"
"These peaks are ignored and are not evaluated during mixing.")
self.showpositiveoverlapCheckBox = QCheckBox("Show Overlaps as Positive")
self.showpositiveoverlapCheckBox.setStyleSheet('QCheckBox{font-size: 12px;}')
self.showpositiveoverlapCheckBox.setToolTip("By default, peaks that overlap are shown as negative peaks.\n"
"This option allows for these peaks to be shown as positive peaks.")
self.resetButton = QPushButton("Reset")
self.resetButton.setStyleSheet("QPushButton{color: orange; font-weight: bold;}")
self.resetButton.setToolTip("Resets the spectrum to the default view.")
self.saveButton = QPushButton("Save")
self.saveButton.setStyleSheet("QPushButton{color: green; font-weight: bold;}")
self.saveButton.setToolTip("Saves the image in the spectrum window.")
self.closeButton = QPushButton("Close")
self.closeButton.setStyleSheet("QPushButton{color: red; font-weight: bold;}")
self.closeButton.setToolTip("Closes this window.")
vbox = QVBoxLayout(self)
self.spectraLabel = QLabel("Simulated Spectra of Mixture %s" % self.mixture_id)
self.spectraLabel.setStyleSheet('QLabel{color: red; font-weight: bold; qproperty-alignment: AlignCenter; '
'font-size: 14px;}')
self.spectraLabel.setToolTip("Shows the simulated spectra of the compounds in this mixture based solely on peaklists.\n"
"Peaks are drawn based on a Lorentzian shape.")
vbox.addWidget(self.spectraLabel)
vbox.addWidget(self.canvas)
ins = "Left-click+drag to pan x-axis / Right-click+drag to zoom x-axis / Scroll-wheel to change intensity scale"
self.instructionLabel = QLabel(ins)
self.instructionLabel.setStyleSheet('QLabel{qproperty-alignment: AlignCenter; font-size: 12px;}')
vbox.addWidget(self.instructionLabel)
gridbox = QGridLayout()
self.compound_legend = {}
for i, compound in enumerate(self.show_list):
self.compound_legend[i] = QPushButtonRight(str(compound))
self.compound_legend[i].setStyleSheet("QPushButton {background-color: %s; font-weight: bold;}" % self.compound_colors[i])
self.compound_legend[i].leftClicked.connect(self.handleLegend)
self.compound_legend[i].rightClicked.connect(self.handleCompoundButtonRight)
self.compound_legend[i].setToolTip("Left-click to toggle the spectra for this compound.\n"
"Right-click to show compound infomation.")
row = int(i / 6)
column = i % 6
gridbox.addWidget(self.compound_legend[i], row, column)
vbox.addLayout(gridbox)
hbox1 = QHBoxLayout()
hbox1.addWidget(self.showroisCheckBox)
hbox1.addWidget(self.showfullroisCheckBox)
hbox1.addWidget(self.showignoredregionsCheckBox)
hbox1.addWidget(self.showignoredpeaksCheckBox)
hbox1.addWidget(self.showpositiveoverlapCheckBox)
#.........这里部分代码省略.........