(self)
Draw the horizontal axis and sets self.scale_x for discrete attributes
Draw the horizontal axis and sets self.scale_x for discrete attributes
Draw the horizontal axis and sets self . scale_x for discrete attributes
def draw_axis_disc(self):
        """
        Draw the horizontal axis and sets self.scale_x for discrete attributes
        """
        assert not self.attribute.is_continuous
        if self.show_stretched:
            if not self.attr_labels:
                return
            step = steps = 10
        else:
            if self.group_var:
                max_box = max(float(np.sum(dist))
                              for dist in self.conts.array_with_unknowns)
            else:
                max_box = float(np.sum(self.dist.array_with_unknowns))
            if max_box == 0:
                self.scale_x = 1
                return
            _, step = compute_scale(0, max_box)
            step = int(step) if step > 1 else 1
            steps = int(math.ceil(max_box / step))
        max_box = step * steps

        bv = self.box_view
        viewrect = bv.viewport().rect().adjusted(15, 15, -15, -30)
        self.scene_width = viewrect.width()

        lab_width = max(lab.boundingRect().width() for lab in self.attr_labels)
        lab_width = max(lab_width, 40)
        lab_width = min(lab_width, self.scene_width / 3)
        self.label_width = lab_width

        right_offset = 0  # offset for the right label
        if not self.show_stretched and self.labels:
            if self.group_var:
                rows = list(zip(self.conts.array_with_unknowns, self.labels))
            else:
                rows = [(self.dist, self.labels[0])]
            # available space left of the 'group labels'
            available = self.scene_width - lab_width - 10
            scale_x = (available - right_offset) / max_box
            max_right = max(sum(dist) * scale_x + 10 +
                            lbl.boundingRect().width()
                            for dist, lbl in rows)
            right_offset = max(0, max_right - max_box * scale_x)

        self.scale_x = scale_x = \
            (self.scene_width - lab_width - 10 - right_offset) / max_box

        self.box_scene.addLine(0, 0, max_box * scale_x, 0, self._pen_axis)
        for val in range(0, step * steps + 1, step):
            l = self.box_scene.addLine(val * scale_x, -1, val * scale_x, 1,
                                       self._pen_axis_tick)
            l.setZValue(100)
            t = self.box_scene.addSimpleText(str(val), self._axis_font)
            t.setPos(val * scale_x - t.boundingRect().width() / 2, 8)
        if self.show_stretched:
            self.scale_x *= 100
def draw_axis_disc ( self ) : assert not self . attribute . is_continuous if self . show_stretched : if not self . attr_labels : return step = steps = 10 else : if self . group_var : max_box = max ( float ( np . sum ( dist ) ) for dist in self . conts . array_with_unknowns ) else : max_box = float ( np . sum ( self . dist . array_with_unknowns ) ) if max_box == 0 : self . scale_x = 1 return _ , step = compute_scale ( 0 , max_box ) step = int ( step ) if step > 1 else 1 steps = int ( math . ceil ( max_box / step ) ) max_box = step * steps bv = self . box_view viewrect = bv . viewport ( ) . rect ( ) . adjusted ( 15 , 15 , - 15 , - 30 ) self . scene_width = viewrect . width ( ) lab_width = max ( lab . boundingRect ( ) . width ( ) for lab in self . attr_labels ) lab_width = max ( lab_width , 40 ) lab_width = min ( lab_width , self . scene_width / 3 ) self . label_width = lab_width right_offset = 0 # offset for the right label if not self . show_stretched and self . labels : if self . group_var : rows = list ( zip ( self . conts . array_with_unknowns , self . labels ) ) else : rows = [ ( self . dist , self . labels [ 0 ] ) ] # available space left of the 'group labels' available = self . scene_width - lab_width - 10 scale_x = ( available - right_offset ) / max_box max_right = max ( sum ( dist ) * scale_x + 10 + lbl . boundingRect ( ) . width ( ) for dist , lbl in rows ) right_offset = max ( 0 , max_right - max_box * scale_x ) self . scale_x = scale_x = ( self . scene_width - lab_width - 10 - right_offset ) / max_box self . box_scene . addLine ( 0 , 0 , max_box * scale_x , 0 , self . _pen_axis ) for val in range ( 0 , step * steps + 1 , step ) : l = self . box_scene . addLine ( val * scale_x , - 1 , val * scale_x , 1 , self . _pen_axis_tick ) l . setZValue ( 100 ) t = self . box_scene . addSimpleText ( str ( val ) , self . _axis_font ) t . setPos ( val * scale_x - t . boundingRect ( ) . width ( ) / 2 , 8 ) if self . show_stretched : self . scale_x *= 100