#NEWLINE# def save_plot( v , k , goal_val , sim_type , generation , score , output_path , plot_title = None , yrange = None , log_plot = False , constraints = None , name = '' ) : #NEWLINE# #INDENT# plt . figure ( ) #NEWLINE# freq = v [ 0 ] #NEWLINE# gain = v [ 1 ] #NEWLINE# if log_plot : #NEWLINE# #INDENT# plt . semilogx ( freq , gain , 'g' , basex = 10 ) #NEWLINE# plt . semilogx ( freq , goal_val , 'b' , basex = 10 ) #NEWLINE# if ( constraints != None ) : #NEWLINE# #INDENT# plt . plot ( * zip ( * constraints ) , marker = '.' , color = 'r' , ls = '' ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# plt . plot ( freq , gain , 'g' ) #NEWLINE# plt . plot ( freq , goal_val , 'b' ) #NEWLINE# if ( constraints != None ) : #NEWLINE# #INDENT# plt . plot ( * zip ( * constraints ) , marker = '.' , color = 'r' , ls = '' ) #NEWLINE# #UNINDENT# #UNINDENT# ax = [ ] #NEWLINE# ax [ 0 : 4 ] = plt . axis ( ) #NEWLINE# if ( yrange != None ) : #NEWLINE# #INDENT# plt . axis ( [ min ( freq ) , max ( freq ) , yrange [ 0 ] , yrange [ 1 ] ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# plt . axis ( [ min ( freq ) , max ( freq ) , min ( ( - 0.5 ) , ( ( - 0.5 ) + min ( goal_val ) ) ) , max ( 1.5 , ( 0.5 + max ( goal_val ) ) ) ] ) #NEWLINE# #UNINDENT# if ( sim_type == 'dc' ) : #NEWLINE# #INDENT# plt . xlabel ( 'Input (V)' ) #NEWLINE# #UNINDENT# if ( sim_type == 'ac' ) : #NEWLINE# #INDENT# plt . xlabel ( 'Input (Hz)' ) #NEWLINE# #UNINDENT# if ( sim_type == 'tran' ) : #NEWLINE# #INDENT# plt . xlabel ( 'Time (s)' ) #NEWLINE# #UNINDENT# if ( plot_title != None ) : #NEWLINE# #INDENT# plt . title ( plot_title ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# plt . title ( k ) #NEWLINE# #UNINDENT# plt . annotate ( ( 'Generation ' + str ( generation ) ) , xy = ( 0.05 , 0.95 ) , xycoords = 'figure fraction' ) #NEWLINE# if ( score != None ) : #NEWLINE# #INDENT# plt . annotate ( ( 'Score ' + '{0:.2f}' . format ( score ) ) , xy = ( 0.75 , 0.95 ) , xycoords = 'figure fraction' ) #NEWLINE# #UNINDENT# plt . grid ( True ) #NEWLINE# plt . grid ( True , which = 'minor' ) #NEWLINE# if ( ( len ( k ) >= 3 ) and ( k [ 1 : 3 ] == 'db' ) ) : #NEWLINE# #INDENT# plt . ylabel ( 'Output (dB)' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( k [ 0 ] == 'v' ) : #NEWLINE# #INDENT# plt . ylabel ( 'Output (V)' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( k [ 0 ] == 'i' ) : #NEWLINE# #INDENT# plt . ylabel ( 'Output (A)' ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# plt . savefig ( path_join ( output_path , ( ( ( ( ( strftime ( '%Y-%m-%d %H:%M:%S' ) + '-' ) + k ) + '-' ) + str ( name ) ) + '.png' ) ) )