def __post_init__(self): self.g = gnuplot.Gnuplot(log=False, terminal='dumb size 79, 24 aspect 2, 1 mono') self.g.set( title=f"'{self.title}'", xlabel=f"'{self.xname}'", ylabel=f"'{self.yname}'", ) if self.xlog: self.g.set("logscale x") if self.ylog: self.g.set("logscale y") # X if self.xmin.lower() != "auto" or self.xmax.lower() != "auto": # drop value xmin = "" if self.xmin == "Auto" else str(self.xmin) xmax = "" if self.xmax == "Auto" else str(self.xmax) self.g.set(f"xrange [{str(xmin)}:{str(xmax)}") # y if self.ymin.lower() != "auto" or self.ymax.lower() != "auto": # drop value ymin = "" if self.ymin == "Auto" else str(self.ymin) ymax = "" if self.ymax == "Auto" else str(self.ymax) self.g.set(f"yrange [{str(ymin)}:{str(ymax)}")
groupedResults[k][1] + results[k][1][i]) j = j + 1 # if j > 5: # f.write(f"{sumVarCosts/j}\t{sumErrors/j}\t{sumVarCostsB/j}\t{sumErrorsB/j}\t{sumVarCostsC/j}\t{sumErrorsC/j}\t{sumVarCostsD/j}\t{sumErrorsD/j}\n") if not PLOT: print ("No output plot file…") sys.exit(0) g = gnuplot.Gnuplot(log = True, output = f'"{__file__}.eps"', term = 'postscript eps color blacktext "Helvetica" 20', multiplot = 'layout 2, 1 spacing 0.5,0.5') g.cmd('set xrange [0:1500]', 'set xtics format ""',) g.cmd('set ylabel "error (second)"', 'set format y "%.1f"', 'set yrange [0:3.5]') g.cmd('set bmargin 0.75') g.plot(f'"{__file__}.dat" u ($0)*{groupBy}+{groupBy}/2:($6)/1000 t "f=0.4" \ w linespoint pt 6 lt rgb "forest-green", \ "{__file__}.dat" u ($0)*{groupBy}+{groupBy}/2:($4)/1000 t "f=0.2" \ w linespoint pt 2 lt rgb "web-blue", \
previous_freq = freqs[idx] if len(freqs) > 0: idx = 0 # If we found some peak, display the speed. # But as we are in a thread, we cannot call any GTK+ functions. # So, add a callback in the glib event loop. if idx is not None: speed = round(get_speed(freqs[idx])) GLib.idle_add(print_label, speed) else: GLib.idle_add(print_label, "--") a = CustomAudio(rate) g = gnuplot.Gnuplot() g.cmd('set terminal wxt font "arial,10" fontscale 1.0 size 1000, 500') g.cmd('set style line 1 lw 3 lc "web-blue"') g.cmd('set yrange [0:6000000]') g.cmd('set title "FFT" ') g.cmd('set title font ",20" norotate') # draw a line for the minimal height of peaks g.cmd("set arrow 1 from graph 0,first %d to graph 1,first %d nohead" % (peak_height, peak_height)) thread = threading.Thread(target=speed_loop) thread.start() box.pack_start(speed_label, True, True, 20)
async def __call__( # type: ignore self, client: discord.Client, message: discord.Message, *, currency_type: CurrencyType, minutes: float, # in minutes **kwargs, ): timestamp = time.time() currency_records = get.currency_price_record(currency_type) currency_records = [ (timestamp - currency_record.timestamp, currency_record.price) for currency_record in currency_records if currency_record.currency_type == currency_type.name and currency_record.timestamp > timestamp - 60 * minutes ] g = gnuplot.Gnuplot(log=True) timestamps = [-round(r[0]) / 60 for r in currency_records] prices = [r[1] for r in currency_records] if timestamps == [] or prices == []: return {**kwargs, "content": "데이터가 없어!"} with tempfile.NamedTemporaryFile(suffix=".png") as temp_png: df = pd.DataFrame(data={"prices": prices}, index=timestamps) g.set("palette defined (" + ", ".join(f"{i + 1} '{color}'" for (i, color) in enumerate( state.coin_constants[currency_type].COLORS)) + ")") g.unset("colorbox") g.plot_data( df, "using 1:2:1 with line lw 2 lc palette", term="pngcairo size 720,480", out='"' + temp_png.name + '"', title=f'"{currency_type_ko(currency_type)} 최근 {minutes}분 그래프"', xlabel='"Minutes"', xrange=f"[{-minutes}:0]", key=None, size="1, 1", origin="0, 0", ) count = 50 while count > 0: if os.stat(temp_png.name).st_size == 0: count -= 1 await asyncio.sleep(0.3) else: size = os.stat(temp_png.name).st_size await asyncio.sleep(0.7) if os.stat(temp_png.name).st_size == size: await message.channel.send( file=discord.File(temp_png.name)) count = 0 else: await asyncio.sleep(0.3) count += 1 # do not proceed afterward return {**kwargs, "is_satisfied": False}
index_list = df.index[df['Temps (seconde)'] == index] if len(index_list) == 1: debit = df["Débit (bytes/sec)"][index_list[0]] df_display.loc[index] = [index, debit] else: df_display.loc[index] = [index, 0] # print(df_display) df_display['Debit moyen'] = df_display["Débit (bytes/sec)"].mean() debit_moyen.append(df_display["Débit (bytes/sec)"].mean()) # Create a Gnuplot instance and set the options at first; g = gnuplot.Gnuplot( log=True, output='"Graphe_Thread-%i_%s.png"' % (client, datetime.datetime.now()), term='pngcairo font "arial,10" fontscale 1.0 size 900, 600', #multiplot = ""DwZ-DXh-zAn-B2E) ) g.plot_data( df_display, 'using "Temps (seconde)" : "Débit (bytes/sec)" notitle with linespoints lw 2 lc "web-blue" ', 'using "Temps (seconde)" : "Debit moyen" notitle with lines lw 2 lc"red" ', # style = 'data linespoints', title='" Analyse de test TLP-RACK "', #logscale = 'y', xrange='[0:%s]' % x_max, yrange='[0:%s]' % y_max, #format = 'x ""', #xtics = '(66, 87, 109, 130, 151, 174, 193, 215, 235)',