本文整理汇总了Python中AnyQt.QtGui.QColor.setAlphaF方法的典型用法代码示例。如果您正苦于以下问题:Python QColor.setAlphaF方法的具体用法?Python QColor.setAlphaF怎么用?Python QColor.setAlphaF使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtGui.QColor
的用法示例。
在下文中一共展示了QColor.setAlphaF方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from AnyQt.QtGui import QColor [as 别名]
# 或者: from AnyQt.QtGui.QColor import setAlphaF [as 别名]
def __init__(self, i, mu1, mu2, sigma1, sigma2, phi, color):
OWPlotItem.__init__(self)
self.outer_box = QGraphicsPolygonItem(self)
self.inner_box = QGraphicsPolygonItem(self)
self.i = i
self.mu1 = mu1
self.mu2 = mu2
self.sigma1 = sigma1
self.sigma2 = sigma2
self.phi = phi
self.twosigmapolygon = QPolygonF([
QPointF(i, mu1 - sigma1), QPointF(i, mu1 + sigma1),
QPointF(i + 1, mu2 + sigma2), QPointF(i + 1, mu2 - sigma2),
QPointF(i, mu1 - sigma1)
])
self.sigmapolygon = QPolygonF([
QPointF(i, mu1 - .5 * sigma1), QPointF(i, mu1 + .5 * sigma1),
QPointF(i + 1, mu2 + .5 * sigma2), QPointF(i + 1, mu2 - .5 * sigma2),
QPointF(i, mu1 - .5 * sigma1)
])
if isinstance(color, tuple):
color = QColor(*color)
color.setAlphaF(.3)
self.outer_box.setBrush(color)
self.outer_box.setPen(QColor(0, 0, 0, 0))
self.inner_box.setBrush(color)
self.inner_box.setPen(color)
示例2: refresh_integral_markings
# 需要导入模块: from AnyQt.QtGui import QColor [as 别名]
# 或者: from AnyQt.QtGui.QColor import setAlphaF [as 别名]
def refresh_integral_markings(dis, markings_list, curveplot):
for m in markings_list:
if m in curveplot.markings:
curveplot.remove_marking(m)
markings_list.clear()
def add_marking(a):
markings_list.append(a)
curveplot.add_marking(a)
for di in dis:
if di is None:
continue # nothing to draw
color = QColor(di.get("color", "red"))
for el in di["draw"]:
if el[0] == "curve":
bs_x, bs_ys, penargs = el[1]
curve = pg.PlotCurveItem()
curve.setPen(pg.mkPen(color=QColor(color), **penargs))
curve.setZValue(10)
curve.setData(x=bs_x, y=bs_ys[0])
add_marking(curve)
elif el[0] == "fill":
(x1, ys1), (x2, ys2) = el[1]
phigh = pg.PlotCurveItem(x1, ys1[0], pen=None)
plow = pg.PlotCurveItem(x2, ys2[0], pen=None)
color = QColor(color)
color.setAlphaF(0.5)
cc = pg.mkBrush(color)
pfill = pg.FillBetweenItem(plow, phigh, brush=cc)
pfill.setZValue(9)
add_marking(pfill)
elif el[0] == "line":
(x1, y1), (x2, y2) = el[1]
line = pg.PlotCurveItem()
line.setPen(pg.mkPen(color=QColor(color), width=4))
line.setZValue(10)
line.setData(x=[x1[0], x2[0]], y=[y1[0], y2[0]])
add_marking(line)
elif el[0] == "dot":
(x, ys) = el[1]
dot = pg.ScatterPlotItem(x=x, y=ys[0])
dot.setPen(pg.mkPen(color=QColor(color), width=5))
dot.setZValue(10)
add_marking(dot)
示例3: display_contingency
# 需要导入模块: from AnyQt.QtGui import QColor [as 别名]
# 或者: from AnyQt.QtGui.QColor import setAlphaF [as 别名]
def display_contingency(self):
"""
Set the contingency to display.
"""
cont = self.contingencies
var, cvar = self.var, self.cvar
if cont is None or not len(cont):
return
self.plot.clear()
self.plot_prob.clear()
self._legend.clear()
self.tooltip_items = []
if self.show_prob:
self.ploti.showAxis('right')
else:
self.ploti.hideAxis('right')
bottomaxis = self.ploti.getAxis("bottom")
bottomaxis.setLabel(var.name)
bottomaxis.resizeEvent()
cvar_values = cvar.values
colors = [QColor(*col) for col in cvar.colors]
if var and var.is_continuous:
bottomaxis.setTicks(None)
weights, cols, cvar_values, curves = [], [], [], []
for i, dist in enumerate(cont):
v, W = dist
if len(v):
weights.append(numpy.sum(W))
cols.append(colors[i])
cvar_values.append(cvar.values[i])
curves.append(ash_curve(
dist, cont, m=OWDistributions.ASH_HIST,
smoothing_factor=self.smoothing_factor))
weights = numpy.array(weights)
sumw = numpy.sum(weights)
weights /= sumw
colors = cols
curves = [(X, Y * w) for (X, Y), w in zip(curves, weights)]
curvesline = [] #from histograms to lines
for X, Y in curves:
X = X + (X[1] - X[0])/2
X = X[:-1]
X = numpy.array(X)
Y = numpy.array(Y)
curvesline.append((X, Y))
for t in ["fill", "line"]:
curve_data = list(zip(curvesline, colors, weights, cvar_values))
for (X, Y), color, w, cval in reversed(curve_data):
item = pg.PlotCurveItem()
pen = QPen(QBrush(color), 3)
pen.setCosmetic(True)
color = QColor(color)
color.setAlphaF(0.2)
item.setData(X, Y/(w if self.relative_freq else 1),
antialias=True, stepMode=False,
fillLevel=0 if t == "fill" else None,
brush=QBrush(color), pen=pen)
self.plot.addItem(item)
if t == "line":
item.tooltip = "{}\n{}={}".format(
"Normalized density " if self.relative_freq else "Density ",
cvar.name, cval)
self.tooltip_items.append((self.plot, item))
if self.show_prob:
all_X = numpy.array(numpy.unique(numpy.hstack([X for X, _ in curvesline])))
inter_X = numpy.array(numpy.linspace(all_X[0], all_X[-1], len(all_X)*2))
curvesinterp = [numpy.interp(inter_X, X, Y) for (X, Y) in curvesline]
sumprob = numpy.sum(curvesinterp, axis=0)
legal = sumprob > 0.05 * numpy.max(sumprob)
i = len(curvesinterp) + 1
show_all = self.show_prob == i
for Y, color, cval in reversed(list(zip(curvesinterp, colors, cvar_values))):
i -= 1
if show_all or self.show_prob == i:
item = pg.PlotCurveItem()
pen = QPen(QBrush(color), 3, style=Qt.DotLine)
pen.setCosmetic(True)
prob = Y[legal] / sumprob[legal]
item.setData(
inter_X[legal], prob, antialias=True, stepMode=False,
fillLevel=None, brush=None, pen=pen)
self.plot_prob.addItem(item)
item.tooltip = "Probability that \n" + cvar.name + "=" + cval
self.tooltip_items.append((self.plot_prob, item))
elif var and var.is_discrete:
bottomaxis.setTicks([list(enumerate(var.values))])
cont = numpy.array(cont)
maxh = 0 #maximal column height
#.........这里部分代码省略.........