def _anchor_circle(self, variables): # minimum visible anchor radius (radius) min_radius = self._get_min_radius() axisitems = [] for anchor, var in zip(self.plotdata.axes, variables[:]): axitem = AnchorItem( line=QLineF(0, 0, *anchor), text=var.name, ) axitem.setVisible(np.linalg.norm(anchor) > min_radius) axitem.setPen(pg.mkPen((100, 100, 100))) axitem.setArrowVisible(True) self.viewbox.addItem(axitem) axisitems.append(axitem) self.plotdata.axisitems = axisitems if self.placement == self.Placement.Circular: return hidecircle = QGraphicsEllipseItem() hidecircle.setRect( QRectF(-min_radius, -min_radius, 2 * min_radius, 2 * min_radius)) _pen = QPen(Qt.lightGray, 1) _pen.setCosmetic(True) hidecircle.setPen(_pen) self.viewbox.addItem(hidecircle) self.plotdata.hidecircle = hidecircle
def _anchor_circle(self): # minimum visible anchor radius (radius) minradius = self.radius / 100 + 1e-5 for item in chain(self.plotdata.anchoritem, self.plotdata.items): self.viewbox.removeItem(item) self.plotdata.anchoritem = [] self.plotdata.items = [] for anchor, var in zip(self.plotdata.anchors, self.data.domain.attributes): if True or np.linalg.norm(anchor) > minradius: axitem = AnchorItem( line=QLineF(0, 0, *anchor), text=var.name, ) axitem.setVisible(np.linalg.norm(anchor) > minradius) axitem.setPen(pg.mkPen((100, 100, 100))) axitem.setArrowVisible(True) self.plotdata.anchoritem.append(axitem) self.viewbox.addItem(axitem) hidecircle = QGraphicsEllipseItem() hidecircle.setRect( QRectF(-minradius, -minradius, 2 * minradius, 2 * minradius)) _pen = QPen(Qt.lightGray, 1) _pen.setCosmetic(True) hidecircle.setPen(_pen) self.viewbox.addItem(hidecircle) self.plotdata.items.append(hidecircle) self.plotdata.hidecircle = hidecircle
def _anchor_circle(self): # minimum visible anchor radius (radius) minradius = self.radius / 100 + 1e-5 for item in chain(self.plotdata.anchoritem, self.plotdata.items): self.viewbox.removeItem(item) self.plotdata.anchoritem = [] self.plotdata.items = [] for anchor, var in zip(self.plotdata.anchors, self.data.domain.attributes): if True or np.linalg.norm(anchor) > minradius: axitem = AnchorItem( line=QLineF(0, 0, *anchor), text=var.name,) axitem.setVisible(np.linalg.norm(anchor) > minradius) axitem.setPen(pg.mkPen((100, 100, 100))) axitem.setArrowVisible(True) self.plotdata.anchoritem.append(axitem) self.viewbox.addItem(axitem) hidecircle = QGraphicsEllipseItem() hidecircle.setRect( QRectF(-minradius, -minradius, 2 * minradius, 2 * minradius)) _pen = QPen(Qt.lightGray, 1) _pen.setCosmetic(True) hidecircle.setPen(_pen) self.viewbox.addItem(hidecircle) self.plotdata.items.append(hidecircle) self.plotdata.hidecircle = hidecircle
def _anchor_circle(self, variables): # minimum visible anchor radius (radius) min_radius = self._get_min_radius() axisitems = [] for anchor, var in zip(self.plotdata.axes, variables[:]): axitem = AnchorItem(line=QLineF(0, 0, *anchor), text=var.name,) axitem.setVisible(np.linalg.norm(anchor) > min_radius) axitem.setPen(pg.mkPen((100, 100, 100))) axitem.setArrowVisible(True) self.viewbox.addItem(axitem) axisitems.append(axitem) self.plotdata.axisitems = axisitems if self.placement == self.Placement.Circular: return hidecircle = QGraphicsEllipseItem() hidecircle.setRect(QRectF(-min_radius, -min_radius, 2 * min_radius, 2 * min_radius)) _pen = QPen(Qt.lightGray, 1) _pen.setCosmetic(True) hidecircle.setPen(_pen) self.viewbox.addItem(hidecircle) self.plotdata.hidecircle = hidecircle
def update_anchors(self): points, labels = self.master.get_anchors() if points is None: return r = self.scaled_radius * np.max(np.linalg.norm(points, axis=1)) if self.anchor_items is None: self.anchor_items = [] for point, label in zip(points, labels): anchor = AnchorItem(line=QLineF(0, 0, *point), text=label) visible = self.always_show_axes or np.linalg.norm(point) > r anchor.setVisible(visible) anchor.setPen(pg.mkPen((100, 100, 100))) self.plot_widget.addItem(anchor) self.anchor_items.append(anchor) else: for anchor, point, label in zip(self.anchor_items, points, labels): anchor.setLine(QLineF(0, 0, *point)) visible = self.always_show_axes or np.linalg.norm(point) > r anchor.setVisible(visible)
def _add_point_items(self): r = self.radius / 100 + 1e-5 for point, var in zip(self._points, self._attributes): axitem = AnchorItem(line=QLineF(0, 0, *point), text=var.name) axitem.setVisible(np.linalg.norm(point) > r) axitem.setPen(pg.mkPen((100, 100, 100))) self.plot_widget.addItem(axitem) self._point_items.append(axitem)
def update_anchors(self): points, labels = self.master.get_anchors() if points is None: return r = self.scaled_radius if self.anchor_items is None: self.anchor_items = [] for point, label in zip(points, labels): anchor = AnchorItem(line=QLineF(0, 0, *point), text=label) anchor.setVisible(np.linalg.norm(point) > r) anchor.setPen(pg.mkPen((100, 100, 100))) anchor.setFont(self.parameter_setter.anchor_font) self.plot_widget.addItem(anchor) self.anchor_items.append(anchor) else: for anchor, point, label in zip(self.anchor_items, points, labels): anchor.setLine(QLineF(0, 0, *point)) anchor.setText(label) anchor.setVisible(np.linalg.norm(point) > r) anchor.setFont(self.parameter_setter.anchor_font)
def update_anchors(self): points, labels = self.master.get_anchors() if points is None: return r = self.scaled_radius * np.max(np.linalg.norm(points, axis=1)) if self.anchor_items is None: self.anchor_items = [] for point, label in zip(points, labels): anchor = AnchorItem(line=QLineF(0, 0, *point)) anchor._label.setToolTip(f"<b>{label}</b>") label = label[:MAX_LABEL_LEN - 3] + "..." if len( label) > MAX_LABEL_LEN else label anchor.setText(label) anchor.setFont(self.parameter_setter.anchor_font) visible = self.always_show_axes or np.linalg.norm(point) > r anchor.setVisible(visible) anchor.setPen(pg.mkPen((100, 100, 100))) self.plot_widget.addItem(anchor) self.anchor_items.append(anchor) else: for anchor, point, label in zip(self.anchor_items, points, labels): anchor.setLine(QLineF(0, 0, *point)) visible = self.always_show_axes or np.linalg.norm(point) > r anchor.setVisible(visible) anchor.setFont(self.parameter_setter.anchor_font)