コード例 #1
0
	def plot( self, font_fname=None ) :
		plt = Gnuplot()
		plt.open()

		plt.xlabel( "Time (s)" )
		plt.ylabel( "$$$ spent (estimate)" )
		plt.set_style( "linespoints" )

		plots = []
		labels = []
		for i in range( self.nplayers ) :
			player = self.kwr.players[i]
			if not player.is_player() :
				continue

			pair = self.split( self.spents[ i ] )
			if not pair :
				continue
			ts, costs = pair

			plt.plot( ts, costs )
			labels.append( sanitize_name( player, xor=True ) )

		plt.legend( labels )
		plt.show()
		plt.close()
コード例 #2
0
	def plot( self, interval, font_fname=None ) :
		plt = Gnuplot()
		plt.open()

		cmds_at_second = self.group_commands_by_time()
		counts_at_second = self.count_player_actions( interval, cmds_at_second )
		# actions counted for that second...

		ts = [ t for t in range( len( counts_at_second ) ) ]
		apmss = self.make_apmss( interval, counts_at_second )
		#apmss[pid][t] = apm at time t, of player pid.

		plt.xlabel( "Time (s)" )
		plt.ylabel( "APM" )

		labels = []

		for i in range( self.nplayers ) :
			player = self.kwr.players[i]
			if not player.is_player() :
				continue

			plt.plot( ts, apmss[ i ] )
			name = sanitize_name( player, xor=True )
			labels.append( name )

		# touch up label of the curve

		# draw legend
		plt.legend( labels )

		avg_apms = self.calc_avg_apm( cmds_at_second )
		avg_apm_texts = self.avg_apm2txts( avg_apms )

		# draw peak arrow.
		self.draw_peak_labels( plt, apmss )

		# now the plot begins.
		plt.write( 'plot \\\n' ) # begin the plot command.

		color = 1
		for pid in range( self.nplayers ) :
			player = self.kwr.players[pid]
			if not player.is_player() :
				continue
			#name = sanitize_name( player, xor=True )
			#print( name, avg_apms[ pid ] )
			plt.write( "%f title \"%s\" linecolor %d linetype 0 linewidth 2, \\\n" % ( avg_apms[ pid ], avg_apm_texts[pid], color ) )
			color += 1

		plt.data_plot_command() # plot apm(player, t) data.

		plt.close()