def print_plot(items, x, y=None, sort=None, fillx=False, title=None, grid=False, marker=None, color=None, background_color=None, axes_color=None): df = items_to_dataframe(items, sort=sort) x_list = df[x].tolist() y_list = df[y].tolist() if y else None _x = df['timestamp'].tolist() if x in DATE_FIELDS else df[x] if y is None: plt.scatter(_x, marker=marker, color=color, fillx=fillx) else: plt.plot(_x, y_list, marker=marker, color=color, fillx=fillx) plt.xticks(_x, x_list) if title is not None: plt.title(title) if grid: plt.grid(True, True) if background_color is not None: plt.canvas_color(background_color) plt.axes_color(background_color) if axes_color is not None: plt.ticks_color(axes_color) plt.show()
def plot_coverage(self, sequence_name, coverage, num_bins=100): try: import plotext as plt except: self.run.warning( "You don't have the `plotext` library to plot data :/ You can " "install it by running `pip install plotext` in your anvi'o " "environment.", header="NO PLOT FOR YOU :(") return plt.clp() plt.title(f"{sequence_name}") plt.xlabel("Position") plt.ylabel("Coverage") plt.plot(coverage, fillx=True) plt.plotsize(self.progress.terminal_width, 25) plt.canvas_color("cloud") plt.axes_color("cloud") plt.ticks_color("iron") try: plt.show() except OSError: self.run.warning( "Redirecting things into files and working with funny TTYs confuse " "the plotting services. Is ok tho.", header="NO PLOT FOR YOU :(") pass
def plotter(x, y, foreground_color, background_color): plt.datetime.set_datetime_form(date_form="%b %Y") plt.plot_date(x, y, marker="dot", color=foreground_color) plt.ticks_color(foreground_color) plt.plotsize(88, 30) plt.canvas_color(background_color) plt.axes_color(background_color)
def plot_score_trace(self, t, R_scores): r = R_scores.shape[0] plt.clear_plot() plt.set_output_file(self._logfile) for i in range(self.g.p["mcmc"]["n_indep"]): if t < r: plt.scatter(R_scores[:t, i], label=str(i), line_color="red") else: plt.scatter(R_scores[np.r_[(t % r):r, 0:(t % r)], i], label=str(i), line_color="red") plt.figsize(80, 20) plt.ticks(4, 4) if t < 1000: xticks = [int(w * t) for w in np.arange(0, 1 + 1 / 3, 1 / 3)] xlabels = [str(round(x / 1000, 1)) + "k" for x in xticks] else: xticks = [0, 333, 666, 999] xlabels = [str(round((x + t) / 1000, 1)) + "k" for x in xticks] plt.xticks(xticks, xlabels) plt.canvas_color("none") plt.axes_color("none") plt.ticks_color("none") plt.show() print(file=self._logfile) self._logfile.flush()
def set_plot(self, earnings, times): y = earnings x = times listofzeros = [0] * len(earnings) ptt.plot(y, line_color='red') ptt.plot(listofzeros, line_color='green') ptt.ylim(-500, -250) ptt.grid(True) ptt.canvas_color("black") ptt.axes_color("black") ptt.ticks_color("cloud") ptt.show()
def main(filea, fileb): if filea is None: # take the second most recent profiling_files = parse_and_sort_profiling_files() filea = profiling_files[-2] if fileb is None: # take the most recent profiling_files = parse_and_sort_profiling_files() fileb = profiling_files[-1] profile_a = pd.read_pickle(filea) profile_b = pd.read_pickle(fileb) merged = pd.merge( profile_a, profile_b, how='left', on=['document_length','document_depth', 'working_depth', 'item_length'] ) plt.clp() bins = 30 plt.hist(merged['tottime_x'], bins, label="profile a") plt.hist(merged['tottime_y'], bins, label="profile b") plt.title("tottime distribution") plt.xlabel("time bins") plt.ylabel("frequency") plt.canvas_color("none") plt.axes_color("none") plt.ticks_color("cloud") plt.figsize(50, 15) plt.show() merged['diff'] = merged['tottime_x'] - merged['tottime_y'] print("") print(f"## avg improvement: {merged['diff'].mean()} seconds ##") print("")
import plotext as plt # format: <<ID:default_value>> scatter_size = <<SCATTER_SIZE:1>> labels = <<LABELS:None>> h = <<HEIGHT:None>> w = <<WIDTH:None>> vv = <<DATA:[]>> if w is not None: plt.figure(figsize=(w*cm, h*cm)) # scatter for ii in range(len(vv)): v = vv[ii] x = [v[2*i] for i in range(len(v)//2)] y = [v[2*i+1] for i in range(len(v)//2) if 2*i + 1 < len(v)] if labels and ii < len(labels): label = labels[ii] plt.scatter(x, y, label=label) else: plt.scatter(x, y) plt.canvas_color('black') plt.axes_color('black') plt.ticks_color('white') if w is not None: plt.plot_size(w, h) plt.show()