本文整理汇总了Python中AnyQt.QtGui.QPixmap.transformed方法的典型用法代码示例。如果您正苦于以下问题:Python QPixmap.transformed方法的具体用法?Python QPixmap.transformed怎么用?Python QPixmap.transformed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtGui.QPixmap
的用法示例。
在下文中一共展示了QPixmap.transformed方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setHistogram
# 需要导入模块: from AnyQt.QtGui import QPixmap [as 别名]
# 或者: from AnyQt.QtGui.QPixmap import transformed [as 别名]
def setHistogram(self, values=None, bins=None, use_kde=False, histogram=None):
""" Set background histogram (or density estimation, violin plot)
The histogram of bins is calculated from values, optionally as a
Gaussian KDE. If histogram is provided, its values are used directly
and other parameters are ignored.
"""
if (values is None or not len(values)) and histogram is None:
self.setPixmap(None)
return
if histogram is not None:
self._histogram = hist = histogram
else:
if bins is None:
bins = min(100, max(10, len(values) // 20))
if use_kde:
hist = gaussian_kde(values,
None if isinstance(use_kde, bool) else use_kde)(
np.linspace(np.min(values), np.max(values), bins))
else:
hist = np.histogram(values, bins)[0]
self._histogram = hist = hist / hist.max()
HEIGHT = self.rect().height() / 2
OFFSET = HEIGHT * .3
pixmap = QPixmap(QSize(len(hist), 2 * (HEIGHT + OFFSET))) # +1 avoids right/bottom frame border shadow
pixmap.fill(Qt.transparent)
painter = QPainter(pixmap)
painter.setPen(QPen(Qt.darkGray))
for x, value in enumerate(hist):
painter.drawLine(x, HEIGHT * (1 - value) + OFFSET,
x, HEIGHT * (1 + value) + OFFSET)
if self.orientation() != Qt.Horizontal:
pixmap = pixmap.transformed(QTransform().rotate(-90))
self.setPixmap(pixmap)