@@ -497,8 +497,11 @@ def mean_label(self, stat, attr, val_name):
497497
498498 def draw_axis (self ):
499499 """Draw the horizontal axis and sets self.scale_x"""
500- bottom = min (stat .a_min for stat in self .stats )
501- top = max (stat .a_max for stat in self .stats )
500+ misssing_stats = not self .stats
501+ stats = self .stats or [BoxData (np .array ([[0. ], [1. ]]))]
502+ mean_labels = self .mean_labels or [self .mean_label (stats [0 ], self .attribute , "" )]
503+ bottom = min (stat .a_min for stat in stats )
504+ top = max (stat .a_max for stat in stats )
502505
503506 first_val , step = compute_scale (bottom , top )
504507 while bottom <= first_val :
@@ -507,8 +510,8 @@ def draw_axis(self):
507510 no_ticks = math .ceil ((top - first_val ) / step ) + 1
508511 top = max (top , first_val + no_ticks * step )
509512
510- gbottom = min (bottom , min (stat .mean - stat .dev for stat in self . stats ))
511- gtop = max (top , max (stat .mean + stat .dev for stat in self . stats ))
513+ gbottom = min (bottom , min (stat .mean - stat .dev for stat in stats ))
514+ gtop = max (top , max (stat .mean + stat .dev for stat in stats ))
512515
513516 bv = self .box_view
514517 viewrect = bv .viewport ().rect ().adjusted (15 , 15 , - 15 , - 30 )
@@ -517,7 +520,7 @@ def draw_axis(self):
517520 # In principle we should repeat this until convergence since the new
518521 # scaling is too conservative. (No chance am I doing this.)
519522 mlb = min (stat .mean + mean_lab .min_x / scale_x
520- for stat , mean_lab in zip (self . stats , self . mean_labels ))
523+ for stat , mean_lab in zip (stats , mean_labels ))
521524 if mlb < gbottom :
522525 gbottom = mlb
523526 self .scale_x = scale_x = viewrect .width () / (gtop - gbottom )
@@ -530,8 +533,10 @@ def draw_axis(self):
530533 l = self .box_scene .addLine (val * scale_x , - 1 , val * scale_x , 1 ,
531534 self ._pen_axis_tick )
532535 l .setZValue (100 )
536+
533537 t = self .box_scene .addSimpleText (
534- self .attribute .repr_val (val ), self ._axis_font )
538+ self .attribute .repr_val (val ) if not misssing_stats else "?" ,
539+ self ._axis_font )
535540 t .setFlags (
536541 t .flags () | QtGui .QGraphicsItem .ItemIgnoresTransformations )
537542 r = t .boundingRect ()
0 commit comments