(self)
Draw the horizontal axis and sets self.scale_x
Draw the horizontal axis and sets self.scale_x
Draw the horizontal axis and sets self . scale_x
def draw_axis(self):
        """Draw the horizontal axis and sets self.scale_x"""
        misssing_stats = not self.stats
        stats = self.stats or [BoxData(np.array([[0.], [1.]]), self.attribute)]
        mean_labels = self.mean_labels or [self.mean_label(stats[0], self.attribute, "")]
        bottom = min(stat.a_min for stat in stats)
        top = max(stat.a_max for stat in stats)

        first_val, step = compute_scale(bottom, top)
        while bottom <= first_val:
            first_val -= step
        bottom = first_val
        no_ticks = math.ceil((top - first_val) / step) + 1
        top = max(top, first_val + no_ticks * step)

        gbottom = min(bottom, min(stat.mean - stat.dev for stat in stats))
        gtop = max(top, max(stat.mean + stat.dev for stat in stats))

        bv = self.box_view
        viewrect = bv.viewport().rect().adjusted(15, 15, -15, -30)
        self.scale_x = scale_x = viewrect.width() / (gtop - gbottom)

        # In principle we should repeat this until convergence since the new
        # scaling is too conservative. (No chance am I doing this.)
        mlb = min(stat.mean + mean_lab.min_x / scale_x
                  for stat, mean_lab in zip(stats, mean_labels))
        if mlb < gbottom:
            gbottom = mlb
            self.scale_x = scale_x = viewrect.width() / (gtop - gbottom)

        self.scene_min_x = gbottom * scale_x
        self.scene_max_x = gtop * scale_x
        self.scene_width = self.scene_max_x - self.scene_min_x

        val = first_val
        last_text = self.scene_min_x
        while True:
            l = self.box_scene.addLine(val * scale_x, -1, val * scale_x, 1,
                                       self._pen_axis_tick)
            l.setZValue(100)
            t = QGraphicsSimpleTextItem(
                self.attribute.str_val(val) if not misssing_stats else "?")
            t.setFont(self._axis_font)
            t.setFlag(QGraphicsItem.ItemIgnoresTransformations)
            r = t.boundingRect()
            x_start = val * scale_x - r.width() / 2
            x_finish = x_start + r.width()
            if x_start > last_text + 10 and x_finish < self.scene_max_x:
                t.setPos(x_start, 8)
                self.box_scene.addItem(t)
                last_text = x_finish
            if val >= top:
                break
            val += step
        self.box_scene.addLine(
            bottom * scale_x - 4, 0, top * scale_x + 4, 0, self._pen_axis)
def draw_axis ( self ) : misssing_stats = not self . stats stats = self . stats or [ BoxData ( np . array ( [ [ 0. ] , [ 1. ] ] ) , self . attribute ) ] mean_labels = self . mean_labels or [ self . mean_label ( stats [ 0 ] , self . attribute , "" ) ] bottom = min ( stat . a_min for stat in stats ) top = max ( stat . a_max for stat in stats ) first_val , step = compute_scale ( bottom , top ) while bottom <= first_val : first_val -= step bottom = first_val no_ticks = math . ceil ( ( top - first_val ) / step ) + 1 top = max ( top , first_val + no_ticks * step ) gbottom = min ( bottom , min ( stat . mean - stat . dev for stat in stats ) ) gtop = max ( top , max ( stat . mean + stat . dev for stat in stats ) ) bv = self . box_view viewrect = bv . viewport ( ) . rect ( ) . adjusted ( 15 , 15 , - 15 , - 30 ) self . scale_x = scale_x = viewrect . width ( ) / ( gtop - gbottom ) # In principle we should repeat this until convergence since the new # scaling is too conservative. (No chance am I doing this.) mlb = min ( stat . mean + mean_lab . min_x / scale_x for stat , mean_lab in zip ( stats , mean_labels ) ) if mlb < gbottom : gbottom = mlb self . scale_x = scale_x = viewrect . width ( ) / ( gtop - gbottom ) self . scene_min_x = gbottom * scale_x self . scene_max_x = gtop * scale_x self . scene_width = self . scene_max_x - self . scene_min_x val = first_val last_text = self . scene_min_x while True : l = self . box_scene . addLine ( val * scale_x , - 1 , val * scale_x , 1 , self . _pen_axis_tick ) l . setZValue ( 100 ) t = QGraphicsSimpleTextItem ( self . attribute . str_val ( val ) if not misssing_stats else "?" ) t . setFont ( self . _axis_font ) t . setFlag ( QGraphicsItem . ItemIgnoresTransformations ) r = t . boundingRect ( ) x_start = val * scale_x - r . width ( ) / 2 x_finish = x_start + r . width ( ) if x_start > last_text + 10 and x_finish < self . scene_max_x : t . setPos ( x_start , 8 ) self . box_scene . addItem ( t ) last_text = x_finish if val >= top : break val += step self . box_scene . addLine ( bottom * scale_x - 4 , 0 , top * scale_x + 4 , 0 , self . _pen_axis )