本文整理汇总了Python中pylab.subplots_adjust方法的典型用法代码示例。如果您正苦于以下问题:Python pylab.subplots_adjust方法的具体用法?Python pylab.subplots_adjust怎么用?Python pylab.subplots_adjust使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pylab
的用法示例。
在下文中一共展示了pylab.subplots_adjust方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: plotKLBoxes
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import subplots_adjust [as 别名]
def plotKLBoxes(data):
cols = [x for x in data.columns if 'KL' in x and 'Class KL' not in x and 'Old' not in x and 'Conventional' not in x and 'Combined' not in x]
cols.reverse()
cols_label, max_kl = 'KL', 9
PL.figure(figsize=(4,5))
pt = data.loc[(data['Combined v Predicted KL'] > 0.75) & (data['Combined v Predicted KL'] < 0.8) & (data['Old v New KL'] > 0.75) & (data['Old v New KL'] < 0.8)]
print(pt['Old Oligo Id'])
PL.boxplot([data[col] for col in cols], positions=range(len(cols)),patch_artist=True,boxprops=dict(facecolor='C2'),medianprops=dict(linewidth=2.5, color='C1'),showfliers=False)
PL.xticks(range(len(cols)),[renameCol(x) for x in cols], rotation='vertical')
for i,col in enumerate(cols):
PL.text(i-0.15, np.median(data[col])+0.02, '%.2f' % np.median(data[col]))
PL.ylabel(cols_label)
PL.subplots_adjust(left=0.1,right=0.95,top=0.95, bottom=0.5)
PL.show(block=False)
saveFig('kl_compare_old_new_predicted_%s' % cols_label.replace(' ',''))
示例2: runAnalysis
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import subplots_adjust [as 别名]
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')
示例3: plotHeatMap
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import subplots_adjust [as 别名]
def plotHeatMap(data, col='KL without null', label=''):
#Compute and collate medians
sel_cols = [x for x in data.columns if col in x]
cmp_meds = data[sel_cols].median(axis=0)
samples = sortSampleNames(getUniqueSamples(sel_cols))
cell_lines = ['CHO', 'E14TG2A', 'BOB','RPE1', 'HAP1','K562','eCAS9','TREX2']
sample_idxs = [(cell_lines.index(parseSampleName(x)[0]),x) for x in getUniqueSamples(sel_cols)]
sample_idxs.sort()
samples = [x[1] for x in sample_idxs]
N = len(samples)
meds = np.zeros((N,N))
for colname in sel_cols:
dir1, dir2 = getDirsFromFilename(colname.split('$')[-1])
idx1, idx2 = samples.index(dir1), samples.index(dir2)
meds[idx1,idx2] = cmp_meds[colname]
meds[idx2,idx1] = cmp_meds[colname]
for i in range(N):
print(' '.join(['%.2f' % x for x in meds[i,:]]))
print( np.median(meds[:,:-4],axis=0))
#Display in Heatmap
PL.figure(figsize=(5,5))
PL.imshow(meds, cmap='hot_r', vmin = 0.0, vmax = 3.0, interpolation='nearest')
PL.colorbar()
PL.xticks(range(N))
PL.yticks(range(N))
PL.title("Median KL") # between %d mutational profiles (for %s with >%d mutated reads)" % (col, len(data), label, MIN_READS))
ax1 = PL.gca()
ax1.set_yticklabels([getSimpleName(x) for x in samples], rotation='horizontal')
ax1.set_xticklabels([getSimpleName(x) for x in samples], rotation='vertical')
PL.subplots_adjust(left=0.25,right=0.95,top=0.95, bottom=0.25)
PL.show(block=False)
saveFig('median_kl_heatmap_cell_lines')
示例4: plotBoxPlotSummary
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import subplots_adjust [as 别名]
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)))
示例5: plot_gallery
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import subplots_adjust [as 别名]
def plot_gallery(images, titles, h, w, n_row=3, n_col=4):
"""Helper function to plot a gallery of portraits"""
pl.figure(figsize=(1.8 * n_col, 2.4 * n_row))
pl.subplots_adjust(bottom=0, left=.01, right=.99, top=.90, hspace=.35)
for i in range(n_row * n_col):
pl.subplot(n_row, n_col, i + 1)
pl.imshow(images[i].reshape((h, w)), cmap=pl.cm.gray)
pl.title(titles[i], size=12)
pl.xticks(())
pl.yticks(())
# plot the result of the prediction on a portion of the test set
示例6: Plot
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import subplots_adjust [as 别名]
def Plot(filename=None, data=None, timemarks=None,
events=None, eventfile=None,
ylim=None, columns=(0, 1),
autoscale=True):
"""Plot from ipython.
Args:
filename (string): name of a data file to plot. This will be loaded
into a DataSet object.
data (DataSet): pre-existing dataset to plot. Mutually exclusive
with filename parameter.
timemarks (string): a time spec indicating a span of time to slice.
eventfile (string): name of data file containing event marks.
events (DataSet): A pre-existing event dataset.
ylim (tuple of (min, max): minimum and maximum Y values to plot.
columns (int, or sequence of ints): The column number, or numbers,
starting from zero that will be extracted out (vertical slice).
autoscale (bool): If True, automatically fit graph scale to data.
False means use a fixed scale (2.5 amp max).
"""
if filename is not None:
data = dataset.DataSet(filename=filename)
if eventfile is not None:
events = dataset.DataSet(filename=eventfile)
if data is None:
print "You should supply a filename or a dataset."
return
if timemarks:
data.timeslice(timemarks)
make_plots(data, ylim=ylim, events=events,
columns=columns, autoscale=autoscale, interactive=True)
pylab.gcf().set_size_inches((9,7))
#plotaxes = pylab.gca()
pylab.subplots_adjust(bottom=0.15)
pylab.ion()
pylab.show()
示例7: plotBarSummary
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import subplots_adjust [as 别名]
def plotBarSummary(all_result_outputs, label='', data_label='PieData', plot_label='bar_plots', stacked=False, combine_reps=False, colors=['C0','C1','C2','C3','C4','C5','C6','C7','C8'], legcol=1, figsize=(6,4), cell_line_order = []):
summaries = [(x[0][data_label], x[1]) for x in all_result_outputs]
mapping = {'BOB':'Human iPSC','E14TG2A':'Mouse ESC'}
if combine_reps:
combined_summaries = []
for cell_line in cell_line_order:
cell_line_summaries = [x[0] for x in summaries if (parseSampleName(x[1])[0] == cell_line)]
combined_summaries.append((avPieSummaries(cell_line_summaries),(cell_line if cell_line not in mapping else mapping[cell_line])))
summaries = combined_summaries
PL.figure(figsize=figsize)
pie_labels = summaries[0][0][1]
N, M = len(pie_labels), len(summaries)
width = 0.8 if stacked else 0.8/N
bottoms = np.array([0.0] * M)
for i, pie_label in enumerate(pie_labels):
bar_heights = [x[0][0][pie_label] for x in summaries]
cell_lines = [parseSampleName(x[1])[0] for x in summaries]
if combine_reps or len(cell_line_order)==0:
bar_pos = [i*width*int(not stacked)+j for j in np.arange(M)]
else:
bar_pos, prev_cl, xticks, xlabels, ncl = [-1.1*width], cell_lines[0], [], [], 0
for cl in cell_lines:
if cl != prev_cl:
bar_pos.append(bar_pos[-1] + width*1.5)
xticks.append((bar_pos[-1]+bar_pos[-ncl])*0.5)
xlabels.append(mapping[prev_cl] if prev_cl in mapping else prev_cl)
ncl = 0
else: bar_pos.append(bar_pos[-1] + width*1.1)
prev_cl = cl
ncl += 1
xticks.append((bar_pos[-1]+bar_pos[-2]-width*0.4)*0.5)
xlabels.append(mapping[prev_cl] if prev_cl in mapping else prev_cl)
bar_pos = bar_pos[1:]
print(pie_label,bar_heights)
PL.bar(bar_pos,bar_heights,width,bottom=bottoms, label=pie_label, color=colors[i])
if stacked:
bottoms += np.array(bar_heights)
PL.legend(loc='center right', ncol=legcol)
#PL.title(label)
if combine_reps:
PL.xticks([x + N/2*width*int(not stacked) for x in np.arange(M)], [x[1] for x in summaries], rotation='vertical')
elif len(cell_line_order)==0:
PL.xticks([x + N/2*width*int(not stacked) for x in np.arange(M)], ['%s' % (getSimpleName(x[1],include_dpi=True) if not combine_reps else x[1]) for x in summaries], rotation='vertical')
else:
PL.xticks(xticks, xlabels, rotation='vertical')
PL.xlim((-1,M*1.6))
PL.subplots_adjust(left=0.15,right=0.95,top=0.95, bottom=0.25)
PL.ylabel('Percent Mutated Reads')
PL.show(block=False)
saveFig(plot_label)
示例8: plot_rels
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import subplots_adjust [as 别名]
def plot_rels(data, labels=None, colors=None, outfile="rels", latent=None, alpha=0.8, title=''):
ns, n = data.shape
if labels is None:
labels = list(map(str, list(range(n))))
ncol = 5
nrow = int(np.ceil(float(n * (n - 1) / 2) / ncol))
fig, axs = pylab.subplots(nrow, ncol)
fig.set_size_inches(5 * ncol, 5 * nrow)
pairs = list(combinations(list(range(n)), 2))
if colors is not None:
colors = (colors - np.min(colors)) / (np.max(colors) - np.min(colors))
for ax, pair in zip(axs.flat, pairs):
diff_x = max(data[:, pair[0]]) - min(data[:, pair[0]])
diff_y = max(data[:, pair[1]]) - min(data[:, pair[1]])
ax.set_xlim([min(data[:, pair[0]]) - 0.05 * diff_x, max(data[:, pair[0]]) + 0.05 * diff_x])
ax.set_ylim([min(data[:, pair[1]]) - 0.05 * diff_y, max(data[:, pair[1]]) + 0.05 * diff_y])
ax.scatter(data[:, pair[0]], data[:, pair[1]], c=colors, cmap=pylab.get_cmap("jet"),
marker='.', alpha=alpha, edgecolors='none', vmin=0, vmax=1)
ax.set_xlabel(shorten(labels[pair[0]]))
ax.set_ylabel(shorten(labels[pair[1]]))
for ax in axs.flat[axs.size - 1:len(pairs) - 1:-1]:
ax.scatter(data[:, 0], data[:, 1], marker='.')
fig.suptitle(title, fontsize=16)
pylab.rcParams['font.size'] = 12 #6
# pylab.draw()
# fig.set_tight_layout(True)
pylab.tight_layout()
pylab.subplots_adjust(top=0.95)
for ax in axs.flat[axs.size - 1:len(pairs) - 1:-1]:
ax.set_visible(False)
filename = outfile + '.png'
if not os.path.exists(os.path.dirname(filename)):
os.makedirs(os.path.dirname(filename))
fig.savefig(outfile + '.png')
pylab.close('all')
return True
# Hierarchical graph visualization utilities