Python pylab.ylim() Examples
The following are 30
code examples of pylab.ylim().
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: __init__.py From EDeN with MIT License | 7 votes |
def plot_roc_curve(y_true, y_score, size=None): """plot_roc_curve.""" false_positive_rate, true_positive_rate, thresholds = roc_curve( y_true, y_score) if size is not None: plt.figure(figsize=(size, size)) plt.axis('equal') plt.plot(false_positive_rate, true_positive_rate, lw=2, color='navy') plt.plot([0, 1], [0, 1], color='gray', lw=1, linestyle='--') plt.xlabel('False positive rate') plt.ylabel('True positive rate') plt.ylim([-0.05, 1.05]) plt.xlim([-0.05, 1.05]) plt.grid() plt.title('Receiver operating characteristic AUC={0:0.2f}'.format( roc_auc_score(y_true, y_score)))
Example #2
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 #3
Source File: proj3d.py From opticspy with MIT License | 7 votes |
def test_lines_dists(): import pylab ax = pylab.gca() xs, ys = (0,30), (20,150) pylab.plot(xs, ys) points = list(zip(xs, ys)) p0, p1 = points xs, ys = (0,0,20,30), (100,150,30,200) pylab.scatter(xs, ys) dist = line2d_seg_dist(p0, p1, (xs[0], ys[0])) dist = line2d_seg_dist(p0, p1, np.array((xs, ys))) for x, y, d in zip(xs, ys, dist): c = Circle((x, y), d, fill=0) ax.add_patch(c) pylab.xlim(-200, 200) pylab.ylim(-200, 200) pylab.show()
Example #4
Source File: plot_mh_analysis.py From SelfTarget with MIT License | 6 votes |
def compareMHK562lines(all_result_outputs, label='', y_axis = 'Percent Non-Null Reads', data_label='RegrLines'): dirnames = [x[1] for x in all_result_outputs] clrs = ['silver','grey','darkgreen','green','lightgreen','royalblue','dodgerblue','skyblue','mediumpurple','orchid','red','orange','salmon'] fig = PL.figure(figsize=(6,6)) leg_handles = [] mh_lens = [3,4,5,6,7,8,9,10,11,12,13,14,15] for mh_len, clr in zip(mh_lens,clrs): regr_lines = [x[0][data_label][mh_len] for x in all_result_outputs] mean_line = np.mean([x[:2] for x in regr_lines], axis=0) leg_handles.append(PL.plot(mean_line[0], mean_line[1], label='MH Len=%d (R=%.1f)' % (mh_len,np.mean([x[2] for x in regr_lines])) , linewidth=2, color=clr )[0]) PL.xlabel('Distance between nearest ends of\nmicrohomologous sequences',fontsize=16) PL.ylabel('Correspondng microhomology-mediated deletion\n as percent of total mutated reads',fontsize=16) PL.tick_params(labelsize=16) PL.legend(handles=[x for x in reversed(leg_handles)], loc='upper right') PL.ylim((0,80)) PL.xlim((0,20)) PL.xticks(range(0,21,5)) PL.show(block=False) saveFig('mh_regr_lines_K562')
Example #5
Source File: util.py From Azimuth with BSD 3-Clause "New" or "Revised" License | 6 votes |
def addqqplotinfo(qnull,M,xl='-log10(P) observed',yl='-log10(P) expected',xlim=None,ylim=None,alphalevel=0.05,legendlist=None,fixaxes=False): distr='log10' pl.plot([0,qnull.max()], [0,qnull.max()],'k') pl.ylabel(xl) pl.xlabel(yl) if xlim is not None: pl.xlim(xlim) if ylim is not None: pl.ylim(ylim) if alphalevel is not None: if distr == 'log10': betaUp, betaDown, theoreticalPvals = _qqplot_bar(M=M,alphalevel=alphalevel,distr=distr) lower = -sp.log10(theoreticalPvals-betaDown) upper = -sp.log10(theoreticalPvals+betaUp) pl.fill_between(-sp.log10(theoreticalPvals),lower,upper,color="grey",alpha=0.5) #pl.plot(-sp.log10(theoreticalPvals),lower,'g-.') #pl.plot(-sp.log10(theoreticalPvals),upper,'g-.') if legendlist is not None: leg = pl.legend(legendlist, loc=4, numpoints=1) # set the markersize for the legend for lo in leg.legendHandles: lo.set_markersize(10) if fixaxes: fix_axes()
Example #6
Source File: rectify.py From facade-segmentation with MIT License | 6 votes |
def plot_original(self): import pylab pylab.title('original') pylab.imshow(self.data) for line in self.lines: p0, p1 = line pylab.plot((p0[0], p1[0]), (p0[1], p1[1]), c='blue', alpha=0.3) for line in self.vlines: p0, p1 = line pylab.plot((p0[0], p1[0]), (p0[1], p1[1]), c='green') for line in self.hlines: p0, p1 = line pylab.plot((p0[0], p1[0]), (p0[1], p1[1]), c='red') pylab.axis('image'); pylab.grid(c='yellow', lw=1) pylab.plt.yticks(np.arange(0, self.l, 100.0)); pylab.xlim(0, self.w) pylab.ylim(self.l, 0)
Example #7
Source File: rectify.py From facade-segmentation with MIT License | 6 votes |
def plot_rectified(self): import pylab pylab.title('rectified') pylab.imshow(self.rectified) for line in self.vlines: p0, p1 = line p0 = self.inv_transform(p0) p1 = self.inv_transform(p1) pylab.plot((p0[0], p1[0]), (p0[1], p1[1]), c='green') for line in self.hlines: p0, p1 = line p0 = self.inv_transform(p0) p1 = self.inv_transform(p1) pylab.plot((p0[0], p1[0]), (p0[1], p1[1]), c='red') pylab.axis('image'); pylab.grid(c='yellow', lw=1) pylab.plt.yticks(np.arange(0, self.l, 100.0)); pylab.xlim(0, self.w) pylab.ylim(self.l, 0)
Example #8
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 #9
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 #10
Source File: megafacade.py From facade-segmentation with MIT License | 6 votes |
def _plot_background(self, bgimage): import pylab as pl # Show the portion of the image behind this facade left, right = self.facade_left, self.facade_right top, bottom = 0, self.mega_facade.rectified.shape[0] if bgimage is not None: pl.imshow(bgimage[top:bottom, left:right], extent=(left, right, bottom, top)) else: # Fit the facade in the plot y0, y1 = pl.ylim() x0, x1 = pl.xlim() x0 = min(x0, left) x1 = max(x1, right) y0 = min(y0, top) y1 = max(y1, bottom) pl.xlim(x0, x1) pl.ylim(y1, y0)
Example #11
Source File: analyser.py From spotpy with MIT License | 6 votes |
def plot_Geweke(parameterdistribution,parametername): '''Input: Takes a list of sampled values for a parameter and his name as a string Output: Plot as seen for e.g. in BUGS or PyMC''' import matplotlib.pyplot as plt # perform the Geweke test Geweke_values = _Geweke(parameterdistribution) # plot the results fig = plt.figure() plt.plot(Geweke_values,label=parametername) plt.legend() plt.title(parametername + '- Geweke_Test') plt.xlabel('Subinterval') plt.ylabel('Geweke Test') plt.ylim([-3,3]) # plot the delimiting line plt.plot( [2]*len(Geweke_values), 'r-.') plt.plot( [-2]*len(Geweke_values), 'r-.')
Example #12
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 #13
Source File: proj3d.py From matplotlib-4-abaqus with MIT License | 6 votes |
def test_lines_dists(): import pylab ax = pylab.gca() xs, ys = (0,30), (20,150) pylab.plot(xs, ys) points = zip(xs, ys) p0, p1 = points xs, ys = (0,0,20,30), (100,150,30,200) pylab.scatter(xs, ys) dist = line2d_seg_dist(p0, p1, (xs[0], ys[0])) dist = line2d_seg_dist(p0, p1, np.array((xs, ys))) for x, y, d in zip(xs, ys, dist): c = Circle((x, y), d, fill=0) ax.add_patch(c) pylab.xlim(-200, 200) pylab.ylim(-200, 200) pylab.show()
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: proj3d.py From Computable with MIT License | 6 votes |
def test_lines_dists(): import pylab ax = pylab.gca() xs, ys = (0,30), (20,150) pylab.plot(xs, ys) points = zip(xs, ys) p0, p1 = points xs, ys = (0,0,20,30), (100,150,30,200) pylab.scatter(xs, ys) dist = line2d_seg_dist(p0, p1, (xs[0], ys[0])) dist = line2d_seg_dist(p0, p1, np.array((xs, ys))) for x, y, d in zip(xs, ys, dist): c = Circle((x, y), d, fill=0) ax.add_patch(c) pylab.xlim(-200, 200) pylab.ylim(-200, 200) pylab.show()
Example #16
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 #17
Source File: View.py From Deep-Spying with Apache License 2.0 | 6 votes |
def plot_barchart(self, data, labels, colors, xlabel, ylabel, xticks, legendloc=1): self.big_figure() index = np.arange(len(data[0][0])) bar_width = 0.25 pylab.grid("on", axis='y') pylab.ylim([0.5, 1.0]) for i in range(0, len(data)): rects = pylab.bar(bar_width / 2 + index + (i * bar_width), data[i][0], bar_width, alpha=0.5, color=colors[i], yerr=data[i][1], error_kw={'ecolor': '0.3'}, label=labels[i]) pylab.legend(loc=legendloc, prop={'size': 12}) pylab.xlabel(xlabel) pylab.ylabel(ylabel) pylab.xticks(bar_width / 2 + index + ((bar_width * (len(data[0]) + 1)) / len(data[0])), xticks)
Example #18
Source File: main.py From scTDA with GNU General Public License v3.0 | 6 votes |
def plot_CDR_correlation(self, doplot=True): """ Displays correlation between sampling time points and CDR. It returns the two parameters of the linear fit, Pearson's r, p-value and standard error. If optional argument 'doplot' is False, the plot is not displayed. """ pel2, tol = self.get_gene(self.rootlane, ignore_log=True) pel = numpy.array([pel2[m] for m in self.pl])*tol dr2 = self.get_gene('_CDR')[0] dr = numpy.array([dr2[m] for m in self.pl]) po = scipy.stats.linregress(pel, dr) if doplot: pylab.scatter(pel, dr, s=9.0, alpha=0.7, c='r') pylab.xlim(min(pel), max(pel)) pylab.ylim(0, max(dr)*1.1) pylab.xlabel(self.rootlane) pylab.ylabel('CDR') xk = pylab.linspace(min(pel), max(pel), 50) pylab.plot(xk, po[1]+po[0]*xk, 'k--', linewidth=2.0) pylab.show() return po
Example #19
Source File: dispersion.py From luscan-devel with GNU General Public License v2.0 | 5 votes |
def dispersion_plot(text, words, ignore_case=False): """ Generate a lexical dispersion plot. :param text: The source text :type text: list(str) or enum(str) :param words: The target words :type words: list of str :param ignore_case: flag to set if case should be ignored when searching text :type ignore_case: bool """ try: import pylab except ImportError: raise ValueError('The plot function requires the matplotlib package (aka pylab).' 'See http://matplotlib.sourceforge.net/') text = list(text) words.reverse() if ignore_case: words_to_comp = map(str.lower, words) text_to_comp = map(str.lower, text) else: words_to_comp = words text_to_comp = text points = [(x,y) for x in range(len(text_to_comp)) for y in range(len(words_to_comp)) if text_to_comp[x] == words_to_comp[y]] if points: x, y = zip(*points) else: x = y = () pylab.plot(x, y, "b|", scalex=.1) pylab.yticks(range(len(words)), words, color="b") pylab.ylim(-1, len(words)) pylab.title("Lexical Dispersion Plot") pylab.xlabel("Word Offset") pylab.show()
Example #20
Source File: c10_20_6_figures.py From Python-for-Finance-Second-Edition with MIT License | 5 votes |
def graph(text,text2=''): pl.xticks(()) pl.yticks(()) pl.xlim(0,30) pl.ylim(0,20) pl.plot([x,x],[0,3]) pl.text(x,-2,"X"); pl.text(0,x,"X") pl.text(x,x*1.7, text, ha='center', va='center',size=10, alpha=.5) pl.text(-5,10,text2,size=25)
Example #21
Source File: util.py From Azimuth with BSD 3-Clause "New" or "Revised" License | 5 votes |
def qqplotp(pv,fileout = None, alphalevel = 0.05,legend=None,xlim=None,ylim=None,ycoord=10,plotsize="652x526",title=None,dohist=True, numbins=50, figsize=[5,5], markersize=2): ''' Read in p-values from filein and make a qqplot adn histogram. If fileout is provided, saves the qqplot only at present. Searches through p until one is found. ''' import pylab as pl pl.ion() fs=8 h1=qqplot(pv, fileout, alphalevel,legend,xlim,ylim,addlambda=True, figsize=figsize, markersize=markersize) #lambda_gc=estimate_lambda(pv) #pl.legend(["gc="+ '%1.3f' % lambda_gc],loc=2) pl.title(title,fontsize=fs) wm=pl.get_current_fig_manager() #e.g. "652x526+100+10 xcoord=100 #wm.window.wm_geometry(plotsize + "+" + str(xcoord) + "+" + str(ycoord)) if dohist: h2=pvalhist(pv, numbins=numbins, figsize=figsize) pl.title(title,fontsize=fs) #wm=pl.get_current_fig_manager() width_height=plotsize.split("x") buffer=10 xcoord=int(xcoord + float(width_height[0])+buffer) #wm.window.wm_geometry(plotsize + "+" + str(xcoord) + "+" + str(ycoord)) else: h2=None return h1,h2
Example #22
Source File: plot_permutations.py From TFCE_mediation with GNU General Public License v3.0 | 5 votes |
def run(opts): arg_permutations = str(opts.input[0]) perm_tfce_max = np.genfromtxt(arg_permutations, delimiter=',') p_array=np.zeros(perm_tfce_max.shape) sorted_perm_tfce_max=sorted(perm_tfce_max, reverse=True) num_perm=perm_tfce_max.shape[0] perm_tfce_mean = perm_tfce_max.mean() perm_tfce_std = perm_tfce_max.std() perm_tfce_max_val = int(sorted_perm_tfce_max[0]) perm_tfce_min_val = int(sorted_perm_tfce_max[(num_perm-1)]) for j in range(num_perm): p_array[j] = 1 - np.true_divide(j,num_perm) sig=int(num_perm*0.05) firstquater=sorted_perm_tfce_max[int(num_perm*0.75)] median=sorted_perm_tfce_max[int(num_perm*0.50)] thirdquater=sorted_perm_tfce_max[int(num_perm*0.25)] sig_tfce=sorted_perm_tfce_max[sig] pl.hist(perm_tfce_max, 100, range=[0,perm_tfce_max_val], label='Max TFCE scores') ylim = pl.ylim() pl.plot([sig_tfce,sig_tfce], ylim, '--g', linewidth=3,label='P[FWE]=0.05') pl.text((sig_tfce*1.4),(ylim[1]*.5), r"$\mu=%0.2f,\ \sigma=%0.2f$" "\n" r"$Critical\ TFCE\ value=%0.0f$" "\n" r"$[%d,\ %d,\ %d,\ %d,\ %d]$" % (perm_tfce_mean,perm_tfce_std,sig_tfce,perm_tfce_min_val,firstquater, median, thirdquater, perm_tfce_max_val), size='medium') pl.ylim(ylim) pl.legend() pl.xlabel('Permutation scores') save("%s.hist" % arg_permutations, ext="png", close=False, verbose=True) pl.show()
Example #23
Source File: util.py From Azimuth with BSD 3-Clause "New" or "Revised" License | 5 votes |
def fix_axes(buffer=0.1): ''' Makes x and y max the same, and the lower limits 0. ''' maxlim=max(pl.xlim()[1],pl.ylim()[1]) pl.xlim([0-buffer,maxlim+buffer]) pl.ylim([0-buffer,maxlim+buffer])
Example #24
Source File: plot_old_new.py From SelfTarget with MIT License | 5 votes |
def runAnalysis(): data = pd.read_csv(getHighDataDir() + '/old_new_kl_summaries.txt', sep='\t').fillna(-1.0) kl_cols = [x for x in data.columns if 'KL' in x and 'Class KL' not in x and 'Old v Old' not in x] max_kl = 9 PL.figure(figsize=(2.5,4)) bps= [] box_types = [('C2','Within Library'),('C0','Between Library')] for i,(clr,box_type) in enumerate(box_types): col_box_data = [data[col] for col in kl_cols if renameCol(col) == box_type] pos = [2*x + i + 1 for x in range(len(col_box_data))] print('KL', box_type, np.median(col_box_data, axis=1)) bps.append(PL.boxplot(col_box_data, positions=pos,patch_artist=True,boxprops=dict(facecolor=clr),showfliers=False)) PL.xticks([1.5,3.5,5.5],['Same\ngRNA','Other\ngRNA','Other\ngRNA\n(Rpt)']) PL.plot([2.5, 2.5],[0, max_kl],'-', color='silver') PL.plot([4.5, 4.5],[0, max_kl],'-', color='silver') PL.xlim((0.5,6.5)) PL.ylim((0,max_kl)) PL.ylabel('KL') PL.subplots_adjust(left=0.1,right=0.95,top=0.95, bottom=0.25) PL.legend([bp["boxes"][0] for bp in bps],[x[1] for x in box_types], loc='upper left') PL.show(block=False) saveFig('kl_compare_old_new_KL')
Example #25
Source File: plot.py From SelfTarget with MIT License | 5 votes |
def plotBoxPlotSummary(all_result_outputs, label='', data_label='', y_label='', plot_label='', cl_order=[]): data_values = [x[0][data_label][0].values for x in all_result_outputs] #sample_names = [getSimpleName(x[1]) + '\n(Median reads = %d)' % x[0][data_label][1] for x in all_result_outputs] sample_names = [getSimpleName(x[1]) for x in all_result_outputs] if len(cl_order)>0: cell_lines = [' '.join(x.split()[:-2]) for x in sample_names] print(cell_lines) reordered_data, reordered_sample_names = [],[] for cell_line in cl_order: for i, cline in enumerate(cell_lines): if cline == cell_line: reordered_data.append(data_values[i]) reordered_sample_names.append(sample_names[i]) sample_names = reordered_sample_names data_values = reordered_data PL.figure(figsize=(5,5)) for i,dvs in enumerate(data_values): print(np.median(dvs)) PL.boxplot([dvs], positions=[i], showfliers=True, sym='.', widths=0.8) PL.xticks(range(len(sample_names)), sample_names, rotation='vertical') PL.xlim((-0.5,len(sample_names)-0.5)) PL.ylim((0,5)) PL.ylabel(y_label) PL.title(label) PL.subplots_adjust(bottom=0.3) PL.show(block=False) saveFig( '%s_%s' % (plot_label, sanitizeLabel(label)))
Example #26
Source File: test_mi.py From rapidtide with Apache License 2.0 | 5 votes |
def test_calc_MI(display=False): inlen = 1000 offset = 100 filename1 = "testdata/lforegressor.txt" filename2 = "testdata/lforegressor.txt" sig1 = tide_io.readvec(filename1) sig2 = np.power(sig1, 2.0) sig3 = np.power(sig1, 3.0) kstart = 3 kend = 100 linmivals = [] sqmivals = [] cubemivals = [] for clustersize in range(kstart, kend, 2): linmivals.append(calc_MI(sig1, sig1, clustersize) / np.log(clustersize)) sqmivals.append(calc_MI(sig2, sig1, clustersize) / np.log(clustersize)) cubemivals.append(calc_MI(sig3, sig1, clustersize) / np.log(clustersize)) if display: plt.figure() #plt.ylim([-1.0, 3.0]) plt.plot(np.array(range(kstart, kend, 2)), np.array(linmivals), 'r') plt.plot(np.array(range(kstart, kend, 2)), np.array(sqmivals), 'g') plt.plot(np.array(range(kstart, kend, 2)), np.array(cubemivals), 'b') #print('maximum occurs at offset', np.argmax(stdcorrelate_result) - midpoint + 1) plt.legend(['Mutual information', 'Squared mutual information', 'Cubed mutual information']) plt.show() aethresh = 10 np.testing.assert_almost_equal(1.0, 1.0, 1e-5)
Example #27
Source File: test_aliasedcorrelate.py From rapidtide with Apache License 2.0 | 5 votes |
def test_aliasedcorrelate(display=False): Fs_hi = 10.0 Fs_lo = 1.0 siginfo = [[1.0, 1.36129345], [0.33, 2.0]] modamp = 0.01 inlenhi = 1000 inlenlo = 100 offset = 0.5 width = 2.5 rangepts = 101 timerange = np.linspace(0.0, width, num=101) - width / 2.0 hiaxis = np.linspace(0.0, 2.0 * np.pi * inlenhi / Fs_hi, num=inlenhi, endpoint=False) loaxis = np.linspace(0.0, 2.0 * np.pi * inlenlo / Fs_lo, num=inlenlo, endpoint=False) sighi = hiaxis * 0.0 siglo = loaxis * 0.0 for theinfo in siginfo: sighi += theinfo[0] * np.sin(theinfo[1] * hiaxis) siglo += theinfo[0] * np.sin(theinfo[1] * loaxis) aliasedcorrelate_result = aliasedcorrelate(sighi, Fs_hi, siglo, Fs_lo, timerange, padvalue=width) thecorrelator = aliasedcorrelator(sighi, Fs_hi, Fs_lo, timerange, padvalue=width) aliasedcorrelate_result2 = thecorrelator.apply(siglo, 0.0) if display: plt.figure() #plt.ylim([-1.0, 3.0]) plt.plot(hiaxis, sighi, 'k') plt.scatter(loaxis, siglo, c='r') plt.legend(['sighi', 'siglo']) plt.figure() plt.plot(timerange, aliasedcorrelate_result, 'k') plt.plot(timerange, aliasedcorrelate_result2, 'r') print('maximum occurs at offset', timerange[np.argmax(aliasedcorrelate_result)]) plt.show() #assert (fastcorrelate_result == stdcorrelate_result).all aethresh = 10 #np.testing.assert_almost_equal(fastcorrelate_result, stdcorrelate_result, aethresh)
Example #28
Source File: __init__.py From EDeN with MIT License | 5 votes |
def draw_graph_row(graphs, index=0, contract=True, n_graphs_per_line=5, size=4, xlim=None, ylim=None, **args): """draw_graph_row.""" dim = len(graphs) size_y = size size_x = size * n_graphs_per_line * args.get('size_x_to_y_ratio', 1) plt.figure(figsize=(size_x, size_y)) if xlim is not None: plt.xlim(xlim) plt.ylim(ylim) else: plt.xlim(xmax=3) for i in range(dim): plt.subplot(1, n_graphs_per_line, i + 1) graph = graphs[i] draw_graph(graph, size=None, pos=graph.graph.get('pos_dict', None), **args) if args.get('file_name', None) is None: plt.show() else: row_file_name = '%d_' % (index) + args['file_name'] plt.savefig(row_file_name, bbox_inches='tight', transparent=True, pad_inches=0) plt.close()
Example #29
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 #30
Source File: __init__.py From EDeN with MIT License | 5 votes |
def plot_precision_recall_curve(y_true, y_score, size=None): """plot_precision_recall_curve.""" precision, recall, thresholds = precision_recall_curve(y_true, y_score) if size is not None: plt.figure(figsize=(size, size)) plt.axis('equal') plt.plot(recall, precision, lw=2, color='navy') plt.xlabel('Recall') plt.ylabel('Precision') plt.ylim([-0.05, 1.05]) plt.xlim([-0.05, 1.05]) plt.grid() plt.title('Precision-Recall AUC={0:0.2f}'.format(average_precision_score( y_true, y_score)))