本文整理汇总了Python中silx.gui.plot.PlotWidget.isYAxisInverted方法的典型用法代码示例。如果您正苦于以下问题:Python PlotWidget.isYAxisInverted方法的具体用法?Python PlotWidget.isYAxisInverted怎么用?Python PlotWidget.isYAxisInverted使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类silx.gui.plot.PlotWidget
的用法示例。
在下文中一共展示了PlotWidget.isYAxisInverted方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: RGBCorrelatorGraph
# 需要导入模块: from silx.gui.plot import PlotWidget [as 别名]
# 或者: from silx.gui.plot.PlotWidget import isYAxisInverted [as 别名]
#.........这里部分代码省略.........
try:
outputFile = os.path.basename(outstr)
except:
outputFile = outstr
outputDir = os.path.dirname(outstr)
self.saveDirectory = outputDir
PyMcaDirs.outputDir = outputDir
#always overwrite for the time being
if len(outputFile) < len(extension[1:]):
outputFile += extension[1:]
elif outputFile[-4:] != extension[1:]:
outputFile += extension[1:]
outputFile = os.path.join(outputDir, outputFile)
if os.path.exists(outputFile):
try:
os.remove(outputFile)
except:
qt.QMessageBox.critical(self, "Save Error",
"Cannot overwrite existing file")
return
if filetype.upper() == "IMAGE":
self.saveGraphImage(outputFile, original=True)
elif filetype.upper() == "ZOOMEDIMAGE":
self.saveGraphImage(outputFile, original=False)
else:
self.saveGraphWidget(outputFile)
def saveGraphImage(self, filename, original=False):
format_ = filename[-3:].upper()
activeImage = self.graph.getActiveImage()
rgbdata = activeImage.getRgbaImageData()
# silx to pymca scale convention (a + b x)
xScale = activeImage.getOrigin()[0], activeImage.getScale()[0]
yScale = activeImage.getOrigin()[1], activeImage.getScale()[1]
if original:
# save whole image
bgradata = numpy.array(rgbdata, copy=True)
bgradata[:, :, 0] = rgbdata[:, :, 2]
bgradata[:, :, 2] = rgbdata[:, :, 0]
else:
shape = rgbdata.shape[:2]
xmin, xmax = self.graph.getGraphXLimits()
ymin, ymax = self.graph.getGraphYLimits()
# save zoomed image, for that we have to get the limits
r0, c0 = convertToRowAndColumn(xmin, ymin, shape, xScale=xScale, yScale=yScale, safe=True)
r1, c1 = convertToRowAndColumn(xmax, ymax, shape, xScale=xScale, yScale=yScale, safe=True)
row0 = int(min(r0, r1))
row1 = int(max(r0, r1))
col0 = int(min(c0, c1))
col1 = int(max(c0, c1))
if row1 < shape[0]:
row1 += 1
if col1 < shape[1]:
col1 += 1
tmpArray = rgbdata[row0:row1, col0:col1, :]
bgradata = numpy.array(tmpArray, copy=True, dtype=rgbdata.dtype)
bgradata[:, :, 0] = tmpArray[:, :, 2]
bgradata[:, :, 2] = tmpArray[:, :, 0]
if self.graph.isYAxisInverted():
qImage = qt.QImage(bgradata, bgradata.shape[1], bgradata.shape[0],
qt.QImage.Format_ARGB32)
else:
qImage = qt.QImage(bgradata, bgradata.shape[1], bgradata.shape[0],
qt.QImage.Format_ARGB32).mirrored(False, True)
pixmap = qt.QPixmap.fromImage(qImage)
if pixmap.save(filename, format_):
return
else:
qt.QMessageBox.critical(self, "Save Error",
"%s" % sys.exc_info()[1])
return
def saveGraphWidget(self, filename):
format_ = filename[-3:].upper()
if hasattr(qt.QPixmap, "grabWidget"):
# Qt4
pixmap = qt.QPixmap.grabWidget(self.graph.getWidgetHandle())
else:
# Qt5
pixmap = self.graph.getWidgetHandle().grab()
if pixmap.save(filename, format_):
return
else:
qt.QMessageBox.critical(self, "Save Error", "%s" % sys.exc_info()[1])
return
def setSaveDirectory(self, wdir):
if os.path.exists(wdir):
self.saveDirectory = wdir
return True
else:
return False
def selectColormap(self):
qt.QMessageBox.information(self, "Open", "Not implemented (yet)")
def _zoomBack(self, pos):
self.graph.getLimitsHistory().pop()