Python pylab.text() Examples
The following are 30
code examples of pylab.text().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
pylab
, or try the search function
.
Example #1
Source File: proj3d.py From opticspy with MIT License | 7 votes |
def test_proj(): import pylab M = test_proj_make_M() ts = ['%d' % i for i in [0,1,2,3,0,4,5,6,7,4]] xs, ys, zs = [0,1,1,0,0, 0,1,1,0,0], [0,0,1,1,0, 0,0,1,1,0], \ [0,0,0,0,0, 1,1,1,1,1] xs, ys, zs = [np.array(v)*300 for v in (xs, ys, zs)] # test_proj_draw_axes(M, s=400) txs, tys, tzs = proj_transform(xs, ys, zs, M) ixs, iys, izs = inv_transform(txs, tys, tzs, M) pylab.scatter(txs, tys, c=tzs) pylab.plot(txs, tys, c='r') for x, y, t in zip(txs, tys, ts): pylab.text(x, y, t) pylab.xlim(-0.2, 0.2) pylab.ylim(-0.2, 0.2) pylab.show()
Example #2
Source File: flexidot_v1.02.py From flexidot with GNU Lesser General Public License v2.1 | 6 votes |
def concatenate_files(file_list, combi_filename="temp_combined.fasta", verbose=False): """ concatenate content of all files in file_list into a combined file named combi_filename """ out_file = open(combi_filename, 'w') text = "" for item in file_list: if verbose: text += item + " " print item, # read in_file linewise and write to out_file in_file = open(item, 'rb') for line in in_file: out_file.write(line.strip()+"\n") in_file.close() out_file.close() if verbose: logprint(text, start=False, printing=False) return combi_filename
Example #3
Source File: plot_i1_summaries.py From SelfTarget with MIT License | 6 votes |
def i1RepeatNucleotides(data, label=''): merged_data = mergeWithIndelData(data) nt_mean_percs, nts = [], ['A','T','G','C'] for nt in nts: nt_data = merged_data.loc[merged_data['Repeat Nucleotide Left'] == nt] nt_mean_percs.append((nt_data['I1_Rpt Left Reads - NonAmb']*100.0/nt_data['Total reads']).mean()) PL.figure(figsize=(3,3)) PL.bar(range(4),nt_mean_percs) for i in range(4): PL.text(i-0.25,nt_mean_percs[i]+0.8,'%.1f' % nt_mean_percs[i]) PL.xticks(range(4),nts) PL.ylim((0,26)) PL.xlabel('PAM distal nucleotide\nadjacent to the cut site') PL.ylabel('I1 repeated left nucleotide\nas percent of total mutated reads') PL.show(block=False) saveFig('i1_rtp_nt_%s' % label)
Example #4
Source File: ML_flow_chart.py From sklearn_pydata2015 with BSD 3-Clause "New" or "Revised" License | 6 votes |
def plot_supervised_chart(annotate=False): create_base(supervised=True) if annotate: fontdict = dict(color='r', weight='bold', size=14) pl.text(1.9, 4.55, 'X = vec.fit_transform(input)', fontdict=fontdict, rotation=20, ha='left', va='bottom') pl.text(3.7, 3.2, 'clf.fit(X, y)', fontdict=fontdict, rotation=20, ha='left', va='bottom') pl.text(1.7, 1.5, 'X_new = vec.transform(input)', fontdict=fontdict, rotation=20, ha='left', va='bottom') pl.text(6.1, 1.5, 'y_new = clf.predict(X_new)', fontdict=fontdict, rotation=20, ha='left', va='bottom')
Example #5
Source File: flexidot_v1.03.py From flexidot with GNU Lesser General Public License v2.1 | 6 votes |
def concatenate_files(file_list, combi_filename="temp_combined.fasta", verbose=False): """ concatenate content of all files in file_list into a combined file named combi_filename """ out_file = open(combi_filename, 'w') text = "" for item in file_list: if verbose: text += item + " " print item, # read in_file linewise and write to out_file in_file = open(item, 'rb') for line in in_file: out_file.write(line.strip()+"\n") in_file.close() out_file.close() if verbose: logprint(text, start=False, printing=False) return combi_filename
Example #6
Source File: proj3d.py From matplotlib-4-abaqus with MIT License | 6 votes |
def test_proj(): import pylab M = test_proj_make_M() ts = ['%d' % i for i in [0,1,2,3,0,4,5,6,7,4]] xs, ys, zs = [0,1,1,0,0, 0,1,1,0,0], [0,0,1,1,0, 0,0,1,1,0], \ [0,0,0,0,0, 1,1,1,1,1] xs, ys, zs = [np.array(v)*300 for v in (xs, ys, zs)] # test_proj_draw_axes(M, s=400) txs, tys, tzs = proj_transform(xs, ys, zs, M) ixs, iys, izs = inv_transform(txs, tys, tzs, M) pylab.scatter(txs, tys, c=tzs) pylab.plot(txs, tys, c='r') for x, y, t in zip(txs, tys, ts): pylab.text(x, y, t) pylab.xlim(-0.2, 0.2) pylab.ylim(-0.2, 0.2) pylab.show()
Example #7
Source File: plot_i1_summaries.py From SelfTarget with MIT License | 6 votes |
def plotMergedI1Repeats(all_result_outputs, label=''): merged_data = mergeSamples(all_result_outputs, ['I1_Rpt Left Reads - NonAmb','Total reads'], data_label='i1IndelData', merge_on=['Oligo Id','Repeat Nucleotide Left']) nt_mean_percs, nts = [], ['A','T','G','C'] for nt in nts: nt_data = merged_data.loc[merged_data['Repeat Nucleotide Left'] == nt] nt_mean_percs.append((nt_data['I1_Rpt Left Reads - NonAmb Sum']*100.0/nt_data['Total reads Sum']).mean()) PL.figure(figsize=(3,3)) PL.bar(range(4),nt_mean_percs) for i in range(4): PL.text(i-0.25,nt_mean_percs[i]+0.8,'%.1f' % nt_mean_percs[i]) PL.xticks(range(4),nts) PL.ylim((0,26)) PL.xlabel('PAM distal nucleotide\nadjacent to the cut site') PL.ylabel('I1 repeated left nucleotide\nas percent of total mutated reads') PL.show(block=False) saveFig('i1_rtp_nt')
Example #8
Source File: compare_overbeek_profiles.py From SelfTarget with MIT License | 6 votes |
def plotInFrame(overbeek_inframes, ours_inframes, oof_sel_overbeek_ids, pred_results_dir): PL.figure(figsize=(4.2,4.2)) data = pd.read_csv(pred_results_dir + '/old_new_kl_predicted_summaries.txt', sep='\t').fillna(-1.0) label1, label2 = 'New 2x800x In Frame Perc', 'New 1600x In Frame Perc' xdata, ydata = data[label1], data[label2] PL.plot(xdata,ydata, '.', label='Synthetic between library (R=%.2f)' % pearsonr(xdata,ydata)[0], color='C0',alpha=0.15) PL.plot(overbeek_inframes, ours_inframes, '^', label='Synthetic vs Endogenous (R=%.2f)' % pearsonr(overbeek_inframes, ours_inframes)[0], color='C1') for (x,y,id) in zip(overbeek_inframes, ours_inframes, oof_sel_overbeek_ids): if abs(x-y) > 25.0: PL.text(x,y,id) PL.plot([0,100],[0,100],'k--') PL.ylabel('Percent In-Frame Mutations') PL.xlabel('Percent In-Frame Mutations') PL.legend() PL.xticks([],[]) PL.yticks([],[]) PL.show(block=False) saveFig('in_frame_full_scatter')
Example #9
Source File: plot_old_new_predictions.py From SelfTarget with MIT License | 6 votes |
def plotInFrameCorr(data): shi_data = pd.read_csv(getHighDataDir() + '/shi_deepseq_frame_shifts.txt',sep='\t') label1, label2 = 'New In Frame Perc', 'Predicted In Frame Per' PL.figure(figsize=(4,4)) xdata, ydata = data[label1], data[label2] PL.plot(xdata,ydata, '.',alpha=0.15) PL.plot(shi_data['Measured Frame Shift'], shi_data['Predicted Frame Shift'], '^', color='orange') for x,y,id in zip(shi_data['Measured Frame Shift'], shi_data['Predicted Frame Shift'],shi_data['ID']): if x-y > 10: PL.text(x,y,id.split('/')[1][:-21]) PL.plot([0,100],[0,100],'k--') PL.title('R=%.3f' % (pearsonr(xdata, ydata)[0])) PL.xlabel('percent in frame mutations (measured)') PL.ylabel('percent in frame mutations (predicted)') PL.ylim((0,80)) PL.xlim((0,80)) PL.show(block=False) saveFig('in_frame_corr_%s_%s' % (label1.replace(' ','_'),label2.replace(' ','_')))
Example #10
Source File: plot.py From pycbc with GNU General Public License v3.0 | 6 votes |
def hist_overflow(val, val_max, **kwds): """ Make a histogram with an overflow bar above val_max """ import pylab, numpy overflow = len(val[val>=val_max]) pylab.hist(val[val<val_max], **kwds) if 'color' in kwds: color = kwds['color'] else: color = None if overflow > 0: rect = pylab.bar(val_max+0.05, overflow, .5, color=color)[0] pylab.text(rect.get_x(), 1.10*rect.get_height(), '%s+' % val_max)
Example #11
Source File: flexidot_v1.01.py From flexidot with GNU Lesser General Public License v2.1 | 6 votes |
def calc_fig_ratio(ncols, nrows, plot_size, verbose=False): """ calculate size ratio for given number of columns (ncols) and rows (nrows) with plot_size as maximum width and length """ ratio = ncols*1./nrows if verbose: text = " ".join([ncols, nrows, ratio]) logprint(text, start=False, printing=True) if ncols >= nrows: figsize_x = plot_size figsize_y = plot_size / ratio else: figsize_x = plot_size * ratio figsize_y = plot_size return figsize_x, figsize_y
Example #12
Source File: flexidot_v1.06.py From flexidot with GNU Lesser General Public License v2.1 | 6 votes |
def calc_fig_ratio(ncols, nrows, plot_size, verbose=False): """ calculate size ratio for given number of columns (ncols) and rows (nrows) with plot_size as maximum width and length """ ratio = ncols*1./nrows if verbose: text = " ".join([ncols, nrows, ratio]) logprint(text, start=False, printing=True) if ncols >= nrows: figsize_x = plot_size figsize_y = plot_size / ratio else: figsize_x = plot_size * ratio figsize_y = plot_size return figsize_x, figsize_y
Example #13
Source File: flexidot_v1.01.py From flexidot with GNU Lesser General Public License v2.1 | 6 votes |
def concatenate_files(file_list, combi_filename="temp_combined.fasta", verbose=False): """ concatenate content of all files in file_list into a combined file named combi_filename """ out_file = open(combi_filename, 'w') text = "" for item in file_list: if verbose: text += item + " " print item, # read in_file linewise and write to out_file in_file = open(item, 'rb') for line in in_file: out_file.write(line.strip()+"\n") in_file.close() out_file.close() if verbose: logprint(text, start=False, printing=False) return combi_filename
Example #14
Source File: proj3d.py From Computable with MIT License | 6 votes |
def test_proj(): import pylab M = test_proj_make_M() ts = ['%d' % i for i in [0,1,2,3,0,4,5,6,7,4]] xs, ys, zs = [0,1,1,0,0, 0,1,1,0,0], [0,0,1,1,0, 0,0,1,1,0], \ [0,0,0,0,0, 1,1,1,1,1] xs, ys, zs = [np.array(v)*300 for v in (xs, ys, zs)] # test_proj_draw_axes(M, s=400) txs, tys, tzs = proj_transform(xs, ys, zs, M) ixs, iys, izs = inv_transform(txs, tys, tzs, M) pylab.scatter(txs, tys, c=tzs) pylab.plot(txs, tys, c='r') for x, y, t in zip(txs, tys, ts): pylab.text(x, y, t) pylab.xlim(-0.2, 0.2) pylab.ylim(-0.2, 0.2) pylab.show()
Example #15
Source File: flexidot_v1.02.py From flexidot with GNU Lesser General Public License v2.1 | 6 votes |
def calc_fig_ratio(ncols, nrows, plot_size, verbose=False): """ calculate size ratio for given number of columns (ncols) and rows (nrows) with plot_size as maximum width and length """ ratio = ncols*1./nrows if verbose: text = " ".join([ncols, nrows, ratio]) logprint(text, start=False, printing=True) if ncols >= nrows: figsize_x = plot_size figsize_y = plot_size / ratio else: figsize_x = plot_size * ratio figsize_y = plot_size return figsize_x, figsize_y
Example #16
Source File: flexidot_v1.05.py From flexidot with GNU Lesser General Public License v2.1 | 6 votes |
def concatenate_files(file_list, combi_filename="temp_combined.fasta", verbose=False): """ concatenate content of all files in file_list into a combined file named combi_filename """ out_file = open(combi_filename, 'w') text = "" for item in file_list: if verbose: text += item + " " print item, # read in_file linewise and write to out_file in_file = open(item, 'rb') for line in in_file: out_file.write(line.strip()+"\n") in_file.close() out_file.close() if verbose: logprint(text, start=False, printing=False) return combi_filename
Example #17
Source File: flexidot_v1.00.py From flexidot with GNU Lesser General Public License v2.1 | 6 votes |
def calc_fig_ratio(ncols, nrows, plot_size, verbose=False): """ calculate size ratio for given number of columns (ncols) and rows (nrows) with plot_size as maximum width and length """ ratio = ncols*1./nrows if verbose: text = " ".join([ncols, nrows, ratio]) logprint(text, start=False, printing=True) if ncols >= nrows: figsize_x = plot_size figsize_y = plot_size / ratio else: figsize_x = plot_size * ratio figsize_y = plot_size return figsize_x, figsize_y
Example #18
Source File: flexidot_v1.06.py From flexidot with GNU Lesser General Public License v2.1 | 6 votes |
def concatenate_files(file_list, combi_filename="temp_combined.fasta", verbose=False): """ concatenate content of all files in file_list into a combined file named combi_filename """ out_file = open(combi_filename, 'w') text = "" for item in file_list: if verbose: text += item + " " print item, # read in_file linewise and write to out_file in_file = open(item, 'rb') for line in in_file: out_file.write(line.strip()+"\n") in_file.close() out_file.close() if verbose: logprint(text, start=False, printing=False) return combi_filename
Example #19
Source File: flexidot_v1.05.py From flexidot with GNU Lesser General Public License v2.1 | 6 votes |
def calc_fig_ratio(ncols, nrows, plot_size, verbose=False): """ calculate size ratio for given number of columns (ncols) and rows (nrows) with plot_size as maximum width and length """ ratio = ncols*1./nrows if verbose: text = " ".join([ncols, nrows, ratio]) logprint(text, start=False, printing=True) if ncols >= nrows: figsize_x = plot_size figsize_y = plot_size / ratio else: figsize_x = plot_size * ratio figsize_y = plot_size return figsize_x, figsize_y
Example #20
Source File: flexidot_v1.04.py From flexidot with GNU Lesser General Public License v2.1 | 6 votes |
def concatenate_files(file_list, combi_filename="temp_combined.fasta", verbose=False): """ concatenate content of all files in file_list into a combined file named combi_filename """ out_file = open(combi_filename, 'w') text = "" for item in file_list: if verbose: text += item + " " print item, # read in_file linewise and write to out_file in_file = open(item, 'rb') for line in in_file: out_file.write(line.strip()+"\n") in_file.close() out_file.close() if verbose: logprint(text, start=False, printing=False) return combi_filename
Example #21
Source File: flexidot_v1.00.py From flexidot with GNU Lesser General Public License v2.1 | 6 votes |
def concatenate_files(file_list, combi_filename="temp_combined.fasta", verbose=False): """ concatenate content of all files in file_list into a combined file named combi_filename """ out_file = open(combi_filename, 'w') text = "" for item in file_list: if verbose: text += item + " " print item, # read in_file linewise and write to out_file in_file = open(item, 'rb') for line in in_file: out_file.write(line.strip()+"\n") in_file.close() out_file.close() if verbose: logprint(text, start=False, printing=False) return combi_filename
Example #22
Source File: flexidot_v1.04.py From flexidot with GNU Lesser General Public License v2.1 | 6 votes |
def calc_fig_ratio(ncols, nrows, plot_size, verbose=False): """ calculate size ratio for given number of columns (ncols) and rows (nrows) with plot_size as maximum width and length """ ratio = ncols*1./nrows if verbose: text = " ".join([ncols, nrows, ratio]) logprint(text, start=False, printing=True) if ncols >= nrows: figsize_x = plot_size figsize_y = plot_size / ratio else: figsize_x = plot_size * ratio figsize_y = plot_size return figsize_x, figsize_y
Example #23
Source File: flexidot_v1.03.py From flexidot with GNU Lesser General Public License v2.1 | 6 votes |
def calc_fig_ratio(ncols, nrows, plot_size, verbose=False): """ calculate size ratio for given number of columns (ncols) and rows (nrows) with plot_size as maximum width and length """ ratio = ncols*1./nrows if verbose: text = " ".join([ncols, nrows, ratio]) logprint(text, start=False, printing=True) if ncols >= nrows: figsize_x = plot_size figsize_y = plot_size / ratio else: figsize_x = plot_size * ratio figsize_y = plot_size return figsize_x, figsize_y
Example #24
Source File: megafacade.py From facade-segmentation with MIT License | 5 votes |
def plot(self, bgimage=None): import pylab as pl self._plot_background(bgimage) ax = pl.gca() y0, y1 = pl.ylim() # r is the width of the thick line we use to show the facade colors r = 5 patch = pl.Rectangle((self.facade_left + r, self.sky_line + r), self.width - 2 * r, self.door_line - self.sky_line - 2 * r, color=self.color, fill=False, lw=2 * r) ax.add_patch(patch) pl.text((self.facade_right + self.facade_left) / 2., (self.door_line + self.sky_line) / 2., '$\sigma^2={:0.2f}$'.format(self.uncertainty_for_windows())) patch = pl.Rectangle((self.facade_left + r, self.door_line + r), self.width - 2 * r, y0 - self.door_line - 2 * r, color=self.mezzanine_color, fill=False, lw=2 * r) ax.add_patch(patch) # Plot the left and right edges in yellow pl.vlines([self.facade_left, self.facade_right], self.sky_line, y0, colors='yellow') # Plot the door line and the roof line pl.hlines([self.door_line, self.sky_line], self.facade_left, self.facade_right, linestyles='dashed', colors='yellow') self.window_grid.plot()
Example #25
Source File: proj3d.py From Computable with MIT License | 5 votes |
def test_proj_draw_axes(M, s=1): import pylab xs, ys, zs = [0, s, 0, 0], [0, 0, s, 0], [0, 0, 0, s] txs, tys, tzs = proj_transform(xs, ys, zs, M) o, ax, ay, az = (txs[0], tys[0]), (txs[1], tys[1]), \ (txs[2], tys[2]), (txs[3], tys[3]) lines = [(o, ax), (o, ay), (o, az)] ax = pylab.gca() linec = LineCollection(lines) ax.add_collection(linec) for x, y, t in zip(txs, tys, ['o', 'x', 'y', 'z']): pylab.text(x, y, t)
Example #26
Source File: flexidot_v1.06.py From flexidot with GNU Lesser General Public License v2.1 | 5 votes |
def time_track(starting_time, show=True): """ calculate time passed since last time measurement """ now = time.time() delta = now - starting_time if show: text = "\n\t %s seconds\n" % str(delta) logprint(text, start=False, printing=True) return now
Example #27
Source File: flexidot_v1.05.py From flexidot with GNU Lesser General Public License v2.1 | 5 votes |
def logprint(text, start=False, printing=True, prefix=""): """ log output to log_file and optionally print """ # define log file name and open file global log_file_name if start and trial_mode: log_file_name = "log_file.txt" if prefix != "" and prefix != None: if not prefix.endswith("-"): prefix = prefix + "-" log_file_name = prefix + log_file_name log_file = open(log_file_name, 'w') log_file.write("Date: %s\n\n" % str(datetime.datetime.now())) elif start: date = datetime.date.today() time = str(datetime.datetime.now()).split(" ")[1].split(".")[0].replace(":", "-") log_file_name = "%s_%s_log_file.txt" % (date, time) if prefix != "" and prefix != None: if not prefix.endswith("-"): prefix = prefix + "-" log_file_name = prefix + log_file_name log_file = open(log_file_name, 'w') log_file.write("Date: %s\n\n" % str(datetime.datetime.now())) else: log_file = open(log_file_name, 'a') # write log (and print) log_file.write(text + "\n") if printing: print text log_file.close()
Example #28
Source File: megafacade.py From facade-segmentation with MIT License | 5 votes |
def plot_facade_cuts(self): facade_sig = self.facade_edge_scores.sum(0) facade_cuts = find_facade_cuts(facade_sig, dilation_amount=self.facade_merge_amount) mu = np.mean(facade_sig) sigma = np.std(facade_sig) w = self.rectified.shape[1] pad=10 gs1 = pl.GridSpec(5, 5) gs1.update(wspace=0.5, hspace=0.0) # set the spacing between axes. pl.subplot(gs1[:3, :]) pl.imshow(self.rectified) pl.vlines(facade_cuts, *pl.ylim(), lw=2, color='black') pl.axis('off') pl.xlim(-pad, w+pad) pl.subplot(gs1[3:, :], sharex=pl.gca()) pl.fill_between(np.arange(w), 0, facade_sig, lw=0, color='red') pl.fill_between(np.arange(w), 0, np.clip(facade_sig, 0, mu+sigma), color='blue') pl.plot(np.arange(w), facade_sig, color='blue') pl.vlines(facade_cuts, facade_sig[facade_cuts], pl.xlim()[1], lw=2, color='black') pl.scatter(facade_cuts, facade_sig[facade_cuts]) pl.axis('off') pl.hlines(mu, 0, w, linestyle='dashed', color='black') pl.text(0, mu, '$\mu$ ', ha='right') pl.hlines(mu + sigma, 0, w, linestyle='dashed', color='gray',) pl.text(0, mu + sigma, '$\mu+\sigma$ ', ha='right') pl.xlim(-pad, w+pad)
Example #29
Source File: flexidot_v1.06.py From flexidot with GNU Lesser General Public License v2.1 | 5 votes |
def logprint(text, start=False, printing=True, prefix=""): """ log output to log_file and optionally print """ # define log file name and open file global log_file_name if start and trial_mode: log_file_name = "log_file.txt" if prefix != "" and prefix != None: if not prefix.endswith("-"): prefix = prefix + "-" log_file_name = prefix + log_file_name log_file = open(log_file_name, 'w') log_file.write("Date: %s\n\n" % str(datetime.datetime.now())) elif start: date = datetime.date.today() time = str(datetime.datetime.now()).split(" ")[1].split(".")[0].replace(":", "-") log_file_name = "%s_%s_log_file.txt" % (date, time) if prefix != "" and prefix != None: if not prefix.endswith("-"): prefix = prefix + "-" log_file_name = prefix + log_file_name log_file = open(log_file_name, 'w') log_file.write("Date: %s\n\n" % str(datetime.datetime.now())) else: log_file = open(log_file_name, 'a') # write log (and print) log_file.write(text + "\n") if printing: print text log_file.close()
Example #30
Source File: plot_otda_jcpot.py From POT with MIT License | 5 votes |
def plot_ax(dec, name): pl.plot([dec[0], dec[0]], [dec[1] - da, dec[1] + da], 'k', alpha=0.5) pl.plot([dec[0] - da, dec[0] + da], [dec[1], dec[1]], 'k', alpha=0.5) pl.text(dec[0] - .5, dec[1] + 2, name) ############################################################################## # Fig 1 : plots source and target samples # ---------------------------------------