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()
def plot_orbit(self, plotfile, nsamp=100): coeffs = self.coeffs[0].T coords = self.coords / 1e3 t = self.time time = np.linspace(self.t_start, self.t_stop, nsamp) if self.centered: time_cent = time - self.t_mean poly = np.asarray([ np.polyval(coeffs[ii, :], time_cent) + mean_coords[ii] for ii in range(3) ]).T else: poly = np.asarray( [np.polyval(coeffs[ii, :], time) for ii in range(3)]).T poly /= 1e3 gpt = Gnuplot() gpt.output(plotfile, term="pngcairo", fontsize=8) gpt.axis_format("x", "") gpt.margins(bmargin=3.5) gpt("set tics font ',8'") gpt.multiplot(3, portrait=True, title="Fit of orbital vectors - " "degree of polynom: {}".format(self.deg)) ylabels = ("X [km]", "Y [km]", "Z [km]") for ii in range(3): gpt.ylabel(ylabels[ii]) points = gpt.data(t, coords[:, ii], title="Orbital coordinates", vith=linedef(point_type="empty_circle")) fit = gpt.data(time, poly[:, ii], title="Fitted polynom", vith="lines") if ii == 2: gpt("set format x") gpt.xlabel("Time [s]") gpt.plot(points, fit)
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()