'Draw the horizontal axis and sets self.scale_x'

def draw_axis(self):

    misssing_stats = (not self.stats)
    stats = (self.stats or [BoxData(np.array([[0.0], [1.0]]), 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))
    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_width = ((gtop - gbottom) * scale_x)
    val = first_val
    while True:
        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((self.attribute.repr_val(val) if (not misssing_stats) else '?'), self._axis_font)
        t.setFlags((t.flags() | QGraphicsItem.ItemIgnoresTransformations))
        r = t.boundingRect()
        t.setPos(((val * scale_x) - (r.width() / 2)), 8)
        if (val >= top):
            break
        val += step
    self.box_scene.addLine(((bottom * scale_x) - 4), 0, ((top * scale_x) + 4), 0, self._pen_axis)
