<s> import matplotlib . pyplot as plt <EOL> import random <EOL> plt . rc ( '<STR_LIT>' , family = '<STR_LIT>' ) <EOL> import argparse <EOL> import re <EOL> import sys <EOL> import os <EOL> import time <EOL> from collections import defaultdict <EOL> from itertools import groupby <EOL> DEFAULT_INPUT = os . path . expanduser ( '<STR_LIT>' ) <EOL> days = '<STR_LIT>' . split ( ) <EOL> def bash_history_map ( ) : <EOL> with open ( DEFAULT_INPUT , '<STR_LIT:r>' ) as histfile : <EOL> R = re . compile ( r'<STR_LIT>' ) <EOL> lines = [ ] <EOL> for line in histfile : <EOL> if R . match ( line ) : <EOL> tm = time . localtime ( float ( line [ <NUM_LIT:1> : ] ) ) <EOL> lines . append ( ( tm . tm_wday , tm . tm_hour ) ) <EOL> return lines <EOL> def time_count_reduce ( time_list ) : <EOL> h = defaultdict ( lambda : <NUM_LIT:0> ) <EOL> for k , g in groupby ( sorted ( time_list ) ) : <EOL> h [ k ] += sum ( <NUM_LIT:1> for _ in g ) <EOL> return h <EOL> h = time_count_reduce ( bash_history_map ( ) ) <EOL> data = [ [ h [ x , y ] for y in range ( <NUM_LIT> ) ] for x in range ( <NUM_LIT:7> ) ] <EOL> maxvalue = max ( max ( i ) for i in data ) <EOL> maxrender = <NUM_LIT> <EOL> xs , ys , rs , ss = [ ] , [ ] , [ ] , [ ] <EOL> for y , d in enumerate ( data ) : <EOL> for x , n in enumerate ( d ) : <EOL> xs . append ( x ) <EOL> ys . append ( y ) <EOL> linear_scale = float ( n ) / float ( maxvalue ) * maxrender <EOL> log_scale = linear_scale ** <NUM_LIT:2> / maxrender <EOL> ss . append ( log_scale ) <EOL> def gen_plot ( ) : <EOL> fig = plt . figure ( figsize = ( <NUM_LIT:8> , title and <NUM_LIT:3> or <NUM_LIT> ) , <EOL> facecolor = '<STR_LIT>' ) <EOL> ax = fig . add_subplot ( '<STR_LIT>' , axisbg = '<STR_LIT>' ) <EOL> if title : <EOL> fig . subplots_adjust ( left = <NUM_LIT> , bottom = <NUM_LIT> , right = <NUM_LIT> , top = <NUM_LIT> ) <EOL> ax . set_title ( title , y = <NUM_LIT> ) . set_color ( '<STR_LIT>' ) <EOL> else : <EOL> fig . subplots_adjust ( left = <NUM_LIT> , bottom = <NUM_LIT> , right = <NUM_LIT> , top = <NUM_LIT> ) <EOL> ax . set_frame_on ( False ) <EOL> ax . scatter ( xs , ys [ : : - <NUM_LIT:1> ] , s = ss , c = '<STR_LIT>' , edgecolor = '<STR_LIT>' ) <EOL> for line in ax . get_xticklines ( ) + ax . get_yticklines ( ) : <EOL> line . set_alpha ( <NUM_LIT:0.0> ) <EOL> dist = - <NUM_LIT> <EOL> ax . plot ( [ dist , <NUM_LIT> ] , [ dist , dist ] , c = '<STR_LIT>' ) <EOL> ax . plot ( [ dist , dist ] , [ dist , <NUM_LIT> ] , c = '<STR_LIT>' ) <EOL> ax . set_xlim ( - <NUM_LIT> , <NUM_LIT> ) <EOL> ax . set_ylim ( - <NUM_LIT> , <NUM_LIT:7> ) <EOL> ax . set_yticks ( range ( <NUM_LIT:7> ) ) <EOL> for tx in ax . set_yticklabels ( days [ : : - <NUM_LIT:1> ] ) : <EOL> tx . set_color ( '<STR_LIT>' ) <EOL> tx . set_size ( <NUM_LIT:8> ) <EOL> ax . set_xticks ( range ( <NUM_LIT> ) ) <EOL> t = '<STR_LIT>' . split ( '<STR_LIT:|>' ) <EOL> for tx in ax . set_xticklabels ( t ) : <EOL> tx . set_color ( '<STR_LIT>' ) <EOL> tx . set_size ( <NUM_LIT> ) <EOL> ax . set_aspect ( '<STR_LIT>' ) <EOL> fig . savefig ( str ( time . time ( ) ) . split ( '<STR_LIT:.>' ) [ <NUM_LIT:0> ] + '<STR_LIT>' ) <EOL> fig . savefig ( "<STR_LIT>" ) <EOL> gen_plot ( ) </s>
