@@ -610,20 +610,24 @@ def __init__(
610610 )
611611 # Draw chart
612612 self .origin = (self .margin , view_height - self .margin )
613- self .create_line (
614- self .origin , (self .margin , self .margin ), width = 2
615- )
613+ # X axis
616614 self .create_line (
617615 self .origin ,
618616 (view_width - self .margin , view_height - self .margin )
619617 )
618+ # Y axis
619+ self .create_line (
620+ self .origin , (self .margin , self .margin ), width = 2
621+ )
622+ # X axis label
620623 self .create_text (
621624 (view_width // 2 , view_height - self .margin ),
622625 text = x_field , anchor = 'n'
623626 )
627+ # Y axis label
624628 self .create_text (
625- (self .margin , view_height // 2 ),
626- text = y_field , angle = 90 , anchor = 's'
629+ (self .margin , view_height // 2 ),
630+ text = y_field , angle = 90 , anchor = 's'
627631 )
628632 self .plot_area = tk .Canvas (
629633 self , background = '#555' ,
@@ -635,8 +639,8 @@ def __init__(
635639
636640 # Draw legend and lines
637641 plot_names = sorted (set ([
638- row [self .plot_by_field ]
639- for row in self .data
642+ row [self .plot_by_field ]
643+ for row in self .data
640644 ]))
641645
642646 color_map = list (zip (plot_names , self .colors ))
@@ -669,10 +673,11 @@ def _plot_line(self, data, color):
669673
670674 def _draw_legend (self , color_map ):
671675 # determine legend
672- y = 10
673- for label , color in color_map :
674- self .plot_area .create_text ((10 , y ), text = label , fill = color , anchor = 'w' )
675- y += 20
676+ for i , (label , color ) in enumerate (color_map ):
677+ self .plot_area .create_text (
678+ (10 , 10 + (i * 20 )),
679+ text = label , fill = color , anchor = 'w'
680+ )
676681
677682
678683class YieldChartView (tk .Frame ):
@@ -692,10 +697,10 @@ def __init__(self, parent, x_axis, y_axis, title):
692697 self .scatter_labels = list ()
693698
694699 def draw_scatter (self , data , color , label ):
695- x , y , s = zip (* data )
696- s = [(x ** 2 )// 2 for x in s ]
700+ x , y , size = zip (* data )
701+ scaled_size = [(s ** 2 )// 2 for s in size ]
697702 scatter = self .axes .scatter (
698- x , y , s ,
703+ x , y , scaled_size ,
699704 c = color , label = label , alpha = 0.5
700705 )
701706 self .scatters .append (scatter )
0 commit comments