本文整理汇总了Python中AnyQt.QtGui.QColor.lighter方法的典型用法代码示例。如果您正苦于以下问题:Python QColor.lighter方法的具体用法?Python QColor.lighter怎么用?Python QColor.lighter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtGui.QColor
的用法示例。
在下文中一共展示了QColor.lighter方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: toggle_node_color_reg
# 需要导入模块: from AnyQt.QtGui import QColor [as 别名]
# 或者: from AnyQt.QtGui.QColor import lighter [as 别名]
def toggle_node_color_reg(self):
"""Update the node color for regression trees"""
def_color = QColor(192, 192, 255)
if self.regression_colors == self.COL_DEFAULT:
brush = QBrush(def_color.lighter(100))
for node in self.scene.nodes():
node.backgroundBrush = brush
elif self.regression_colors == self.COL_INSTANCE:
max_insts = len(self.model.instances)
for node in self.scene.nodes():
node.backgroundBrush = QBrush(def_color.lighter(
120 - 20 * len(node.node_inst.subset) / max_insts))
elif self.regression_colors == self.COL_MEAN:
minv = np.nanmin(self.dataset.Y)
maxv = np.nanmax(self.dataset.Y)
fact = 1 / (maxv - minv) if minv != maxv else 1
colors = self.scene.colors
for node in self.scene.nodes():
node.backgroundBrush = QBrush(
colors[fact * (node.node_inst.value[0] - minv)])
else:
nodes = list(self.scene.nodes())
variances = [node.node_inst.value[1] for node in nodes]
max_var = max(variances)
for node, var in zip(nodes, variances):
node.backgroundBrush = QBrush(def_color.lighter(
120 - 20 * var / max_var))
self.scene.update()
示例2: toggle_node_color_reg
# 需要导入模块: from AnyQt.QtGui import QColor [as 别名]
# 或者: from AnyQt.QtGui.QColor import lighter [as 别名]
def toggle_node_color_reg(self):
"""Update the node color for regression trees"""
def_color = QColor(192, 192, 255)
if self.regression_colors == self.COL_DEFAULT:
brush = QBrush(def_color.lighter(100))
for node in self.scene.nodes():
node.backgroundBrush = brush
elif self.regression_colors == self.COL_INSTANCE:
max_insts = len(self.tree_adapter.get_instances_in_nodes(
[self.tree_adapter.root]))
for node in self.scene.nodes():
node_insts = len(self.tree_adapter.get_instances_in_nodes(
[node.node_inst]))
node.backgroundBrush = QBrush(def_color.lighter(
120 - 20 * node_insts / max_insts))
elif self.regression_colors == self.COL_MEAN:
minv = np.nanmin(self.dataset.Y)
maxv = np.nanmax(self.dataset.Y)
fact = 1 / (maxv - minv) if minv != maxv else 1
colors = self.scene.colors
for node in self.scene.nodes():
node_mean = self.tree_adapter.get_distribution(node.node_inst)[0][0]
node.backgroundBrush = QBrush(colors[fact * (node_mean - minv)])
else:
nodes = list(self.scene.nodes())
variances = [self.tree_adapter.get_distribution(node.node_inst)[0][1]
for node in nodes]
max_var = max(variances)
for node, var in zip(nodes, variances):
node.backgroundBrush = QBrush(def_color.lighter(
120 - 20 * var / max_var))
self.scene.update()
示例3: make_color_legend
# 需要导入模块: from AnyQt.QtGui import QColor [as 别名]
# 或者: from AnyQt.QtGui.QColor import lighter [as 别名]
def make_color_legend(self):
color_index = self.get_color_index()
if color_index == -1:
return
color_var = self.domain[color_index]
use_shape = self.get_shape_index() == color_index
if color_var.is_discrete:
if not self.legend:
self.create_legend()
palette = self.discrete_palette
for i, value in enumerate(color_var.values):
color = QColor(*palette.getRGB(i))
brush = color.lighter(self.DarkerValue)
self.legend.addItem(
ScatterPlotItem(
pen=color, brush=brush, size=10,
symbol=self.CurveSymbols[i] if use_shape else "o"),
escape(value))
else:
legend = self.color_legend = LegendItem()
legend.setParentItem(self.plot_widget.getViewBox())
legend.restoreAnchor(self.__color_legend_anchor)
label = PaletteItemSample(self.continuous_palette, self.scale)
legend.addItem(label, "")
legend.setGeometry(label.boundingRect())
示例4: _setup_plot
# 需要导入模块: from AnyQt.QtGui import QColor [as 别名]
# 或者: from AnyQt.QtGui.QColor import lighter [as 别名]
def _setup_plot(self):
"""Setup the plot with new curve data."""
assert self.data is not None
data, domain = self.data, self.data.domain
if is_discrete(domain.class_var):
class_col_data, _ = data.get_column_view(domain.class_var)
group_indices = [np.flatnonzero(class_col_data == i)
for i in range(len(domain.class_var.values))]
else:
group_indices = [np.arange(len(data))]
X = np.arange(1, len(domain.attributes)+1)
groups = []
for i, indices in enumerate(group_indices):
if self.classes:
color = self.class_colors[i]
else:
color = QColor(Qt.darkGray)
group_data = data[indices, :]
plot_x, plot_y, connect = disconnected_curve_data(group_data.X, x=X)
color.setAlpha(200)
lightcolor = QColor(color.lighter(factor=150))
lightcolor.setAlpha(150)
pen = QPen(color, 2)
pen.setCosmetic(True)
lightpen = QPen(lightcolor, 1)
lightpen.setCosmetic(True)
hoverpen = QPen(pen)
hoverpen.setWidth(2)
curve = pg.PlotCurveItem(
x=plot_x, y=plot_y, connect=connect,
pen=lightpen, symbolSize=2, antialias=True,
)
self.graph.addItem(curve)
hovercurves = []
for index, profile in zip(indices, group_data.X):
hcurve = HoverCurve(x=X, y=profile, pen=hoverpen,
antialias=True)
hcurve.setToolTip('{}'.format(index))
hcurve._data_index = index
hovercurves.append(hcurve)
self.graph.addItem(hcurve)
mean = np.nanmean(group_data.X, axis=0)
meancurve = pg.PlotDataItem(
x=X, y=mean, pen=pen, size=5, symbol="o", pxMode=True,
symbolSize=5, antialias=True
)
hoverpen = QPen(hoverpen)
hoverpen.setWidth(5)
hc = HoverCurve(x=X, y=mean, pen=hoverpen, antialias=True)
hc.setFlag(QGraphicsItem.ItemIsSelectable, False)
self.graph.addItem(hc)
self.graph.addItem(meancurve)
self.legend_items.append(meancurve)
q1, q2, q3 = np.nanpercentile(group_data.X, [25, 50, 75], axis=0)
# TODO: implement and use a box plot item
errorbar = pg.ErrorBarItem(
x=X, y=mean,
bottom=np.clip(mean - q1, 0, mean - q1),
top=np.clip(q3 - mean, 0, q3 - mean),
beam=0.5
)
self.graph.addItem(errorbar)
groups.append(
namespace(
data=group_data, indices=indices, profiles=curve,
hovercurves=hovercurves, mean=meancurve, boxplot=errorbar)
)
self.__groups = groups
self.__update_visibility()
self.__update_tooltips()
示例5: add_points
# 需要导入模块: from AnyQt.QtGui import QColor [as 别名]
# 或者: from AnyQt.QtGui.QColor import lighter [as 别名]
def add_points():
nonlocal cur, image_token
if image_token != self._image_token:
return
batch = visible[cur:cur + self.N_POINTS_PER_ITER]
batch_lat = lat[batch]
batch_lon = lon[batch]
x, y = self.Projection.latlon_to_easting_northing(batch_lat, batch_lon)
x, y = self.Projection.easting_northing_to_pixel(x, y, zoom, origin, map_pane_pos)
if self._jittering:
dx, dy = self._jittering_offsets[batch].T
x, y = x + dx, y + dy
colors = (self._colorgen.getRGB(self._scaled_color_values[batch]).tolist()
if self._color_attr else
repeat((0xff, 0, 0)))
sizes = self._size_coef * \
(self._sizes[batch] if self._size_attr else np.tile(10, len(batch)))
opacity_subset, opacity_rest = self._opacity, int(.8 * self._opacity)
for x, y, is_selected, size, color, _in_subset in \
zip(x, y, selected[batch], sizes, colors, in_subset[batch]):
pensize2, selpensize2 = (.35, 1.5) if size >= 5 else (.15, .7)
pensize2 *= self._size_coef
selpensize2 *= self._size_coef
size2 = size / 2
if is_selected:
painter.setPen(QPen(QBrush(Qt.green), 2 * selpensize2))
painter.drawEllipse(x - size2 - selpensize2,
y - size2 - selpensize2,
size + selpensize2,
size + selpensize2)
color = QColor(*color)
if _in_subset:
color.setAlpha(opacity_subset)
painter.setBrush(QBrush(color))
painter.setPen(QPen(QBrush(color.darker(180)), 2 * pensize2))
else:
color.setAlpha(opacity_rest)
painter.setBrush(Qt.NoBrush)
painter.setPen(QPen(QBrush(color.lighter(120)), 2 * pensize2))
painter.drawEllipse(x - size2 - pensize2,
y - size2 - pensize2,
size + pensize2,
size + pensize2)
im.save(self._overlay_image_path, 'PNG')
self.evalJS('markersImageLayer.setUrl("{}#{}"); 0;'
.format(self.toFileURL(self._overlay_image_path),
np.random.random()))
cur += self.N_POINTS_PER_ITER
if cur < len(visible):
QTimer.singleShot(10, add_points)
self._owwidget.progressBarAdvance(100 / n_iters, None)
else:
self._owwidget.progressBarFinished(None)
self._image_token = None