Python pylab.rcParams() Examples
The following are 4
code examples of pylab.rcParams().
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: vis_corex.py From bio_corex with Apache License 2.0 | 5 votes |
def plot_pairplots(data, labels, alpha, mis, column_label, topk=5, prefix='', focus=''): cmap = sns.cubehelix_palette(as_cmap=True, light=.9) plt.rcParams.update({'font.size': 32}) m, nv = mis.shape for j in range(m): inds = np.where(np.logical_and(alpha[j] > 0, mis[j] > 0.))[0] inds = inds[np.argsort(- alpha[j, inds] * mis[j, inds])][:topk] if focus in column_label: ifocus = column_label.index(focus) if not ifocus in inds: inds = np.insert(inds, 0, ifocus) if len(inds) >= 2: plt.clf() subdata = data[:, inds] columns = [column_label[i] for i in inds] subdata = pd.DataFrame(data=subdata, columns=columns) try: sns.pairplot(subdata, kind="reg", diag_kind="kde", height=5, dropna=True) filename = '{}/pairplots_regress/group_num={}.pdf'.format(prefix, j) if not os.path.exists(os.path.dirname(filename)): os.makedirs(os.path.dirname(filename)) plt.suptitle("Latent factor {}".format(j), y=1.01) plt.savefig(filename, bbox_inches='tight') plt.clf() except: pass subdata['Latent factor'] = labels[:,j] try: sns.pairplot(subdata, kind="scatter", dropna=True, vars=subdata.columns.drop('Latent factor'), hue="Latent factor", diag_kind="kde", height=5) filename = '{}/pairplots/group_num={}.pdf'.format(prefix, j) if not os.path.exists(os.path.dirname(filename)): os.makedirs(os.path.dirname(filename)) plt.suptitle("Latent factor {}".format(j), y=1.01) plt.savefig(filename, bbox_inches='tight') plt.close('all') except: pass
Example #2
Source File: plot.py From SelfTarget with MIT License | 5 votes |
def saveFig(fig_fileprefix, bbox=True): PL.rcParams['svg.fonttype'] = 'none' for ftype in ['svg','png']: if FIG_TYPE == 'both' or FIG_TYPE==ftype: if bbox: PL.savefig(getPlotDir() + '/' + fig_fileprefix +'.'+ftype, bbox_inches='tight') else: PL.savefig(getPlotDir() + '/' + fig_fileprefix +'.'+ftype)
Example #3
Source File: vis_corex.py From bio_corex with Apache License 2.0 | 4 votes |
def plot_rels(data, labels=None, colors=None, outfile="rels", latent=None, alpha=0.8): ns, n = data.shape if labels is None: labels = list(map(str, range(n))) ncol = 5 # ncol = 4 nrow = int(np.ceil(float(n * (n - 1) / 2) / ncol)) #nrow=1 #pylab.rcParams.update({'figure.autolayout': True}) fig, axs = pylab.subplots(nrow, ncol) fig.set_size_inches(5 * ncol, 5 * nrow) #fig.set_canvas(pylab.gcf().canvas) pairs = list(combinations(range(n), 2)) #[:4] pairs = sorted(pairs, key=lambda q: q[0]**2+q[1]**2) # Puts stronger relationships first if colors is not None: colors = (colors - np.min(colors)) / (np.max(colors) - np.min(colors)).clip(1e-7) for ax, pair in zip(axs.flat, pairs): if latent is None: ax.scatter(data[:, pair[0]], data[:, pair[1]], marker='.', edgecolors='none', alpha=alpha) else: # cs = 'rgbcmykrgbcmyk' markers = 'x+.o,<>^^<>,+x.' for j, ind in enumerate(np.unique(latent)): inds = (latent == ind) ax.scatter(data[inds, pair[0]], data[inds, pair[1]], c=colors[inds], cmap=pylab.get_cmap("jet"), marker=markers[j], alpha=0.5, 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='.') pylab.rcParams['font.size'] = 12 #6 pylab.draw() #fig.set_tight_layout(True) fig.tight_layout() 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') #df') pylab.close('all') return True
Example #4
Source File: vis_corex.py From LinearCorex with GNU Affero General Public License v3.0 | 4 votes |
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