Python matplotlib.pylab.xlabel() Examples
The following are 30
code examples of matplotlib.pylab.xlabel().
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
matplotlib.pylab
, or try the search function
.
Example #1
Source File: demo_mi.py From Building-Machine-Learning-Systems-With-Python-Second-Edition with MIT License | 6 votes |
def plot_entropy(): pylab.clf() pylab.figure(num=None, figsize=(5, 4)) title = "Entropy $H(X)$" pylab.title(title) pylab.xlabel("$P(X=$coin will show heads up$)$") pylab.ylabel("$H(X)$") pylab.xlim(xmin=0, xmax=1.1) x = np.arange(0.001, 1, 0.001) y = -x * np.log2(x) - (1 - x) * np.log2(1 - x) pylab.plot(x, y) # pylab.xticks([w*7*24 for w in [0,1,2,3,4]], ['week %i'%(w+1) for w in # [0,1,2,3,4]]) pylab.autoscale(tight=True) pylab.grid(True) filename = "entropy_demo.png" pylab.savefig(os.path.join(CHART_DIR, filename), bbox_inches="tight")
Example #2
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 #3
Source File: electronic.py From pyiron with BSD 3-Clause "New" or "Revised" License | 6 votes |
def plot_fermi_dirac(self): """ Plots the obtained eigenvalue vs occupation plot """ try: import matplotlib.pylab as plt except ModuleNotFoundError: import matplotlib.pyplot as plt arg = np.argsort(self.eigenvalues) plt.plot( self.eigenvalues[arg], self.occupancies[arg], linewidth=2.0, color="blue" ) plt.axvline(self.efermi, linewidth=2.0, linestyle="dashed", color="black") plt.xlabel("Energies (eV)") plt.ylabel("Occupancy") return plt
Example #4
Source File: plot.py From Tacotron2-PyTorch with MIT License | 6 votes |
def plot_alignment_to_numpy(alignment, info=None): fig, ax = plt.subplots(figsize=(6, 4)) im = ax.imshow(alignment, aspect='auto', origin='lower', interpolation='none') fig.colorbar(im, ax=ax) xlabel = 'Decoder timestep' if info is not None: xlabel += '\n\n' + info plt.xlabel(xlabel) plt.ylabel('Encoder timestep') plt.tight_layout() fig.canvas.draw() data = save_figure_to_numpy(fig) plt.close() return data
Example #5
Source File: BirthMoveTopicModel.py From refinery with MIT License | 6 votes |
def viz_missing_docwordfreq_stats(DocWordFreq_emp, DocWordFreq_model): from matplotlib import pylab DocWordFreq_missing = np.maximum(DocWordFreq_emp - DocWordFreq_model, 0) nnzEmp = count_num_nonzero(DocWordFreq_emp) nnzMiss = count_num_nonzero(DocWordFreq_missing) frac_nzMiss = nnzMiss / float(nnzEmp) nzMissPerDoc = np.sum(DocWordFreq_missing > 0, axis=1) CDF_nzMissPerDoc = np.sort(nzMissPerDoc) nzMissPerWord = np.sum(DocWordFreq_missing > 0, axis=0) CDF_nzMissPerWord = np.sort(nzMissPerWord) pylab.subplot(1,2,1) pylab.plot(CDF_nzMissPerDoc) pylab.ylabel('Num Nonzero Entries in Doc') pylab.xlabel('Document rank | frac= %.4f'% (frac_nzMiss)) pylab.subplot(1,2,2) pylab.plot(CDF_nzMissPerWord) pylab.ylabel('Num Nonzero Entries per Word') pylab.xlabel('Word rank') pylab.show(block=True)
Example #6
Source File: trajectory.py From notebook-molecular-visualization with Apache License 2.0 | 6 votes |
def plot(traj, x, y, **kwargs): """ Create a matplotlib plot of property x against property y Args: x,y (str): names of the properties **kwargs (dict): kwargs for :meth:`matplotlib.pylab.plot` Returns: List[matplotlib.lines.Lines2D]: the lines that were plotted """ from matplotlib import pylab xl = yl = None if type(x) is str: strx = x x = getattr(traj, x) xl = '%s / %s' % (strx, getattr(x, 'units', 'dimensionless')) if type(y) is str: stry = y y = getattr(traj, y) yl = '%s / %s' % (stry, getattr(y, 'units', 'dimensionless')) plt = pylab.plot(x, y, **kwargs) pylab.xlabel(xl); pylab.ylabel(yl); pylab.grid() return plt
Example #7
Source File: utils.py From Building-Machine-Learning-Systems-With-Python-Second-Edition with MIT License | 6 votes |
def plot_roc(auc_score, name, tpr, fpr, label=None): pylab.clf() pylab.figure(num=None, figsize=(5, 4)) pylab.grid(True) pylab.plot([0, 1], [0, 1], 'k--') pylab.plot(fpr, tpr) pylab.fill_between(fpr, tpr, alpha=0.5) pylab.xlim([0.0, 1.0]) pylab.ylim([0.0, 1.0]) pylab.xlabel('False Positive Rate') pylab.ylabel('True Positive Rate') pylab.title('ROC curve (AUC = %0.2f) / %s' % (auc_score, label), verticalalignment="bottom") pylab.legend(loc="lower right") filename = name.replace(" ", "_") pylab.savefig( os.path.join(CHART_DIR, "roc_" + filename + ".png"), bbox_inches="tight")
Example #8
Source File: helpers.py From NeMo with Apache License 2.0 | 6 votes |
def plot_gate_outputs_to_numpy(gate_targets, gate_outputs): fig, ax = plt.subplots(figsize=(12, 3)) ax.scatter( range(len(gate_targets)), gate_targets, alpha=0.5, color='green', marker='+', s=1, label='target', ) ax.scatter( range(len(gate_outputs)), gate_outputs, alpha=0.5, color='red', marker='.', s=1, label='predicted', ) plt.xlabel("Frames (Green target, Red predicted)") plt.ylabel("Gate State") plt.tight_layout() fig.canvas.draw() data = save_figure_to_numpy(fig) plt.close() return data
Example #9
Source File: interfacemethod.py From pyiron with BSD 3-Clause "New" or "Revised" License | 6 votes |
def plot_equilibration(temperature_next, strain_lst, nve_run_time_steps, project_parameter, debug_plot=True): if debug_plot: for strain in strain_lst: job_name = get_nve_job_name( temperature_next=temperature_next, strain=strain, steps_lst=project_parameter['nve_run_time_steps_lst'], nve_run_time_steps=nve_run_time_steps ) ham_nve = project_parameter['project'].load(job_name) plt.plot(ham_nve['output/generic/temperature'], label='strain: ' + str(strain)) plt.axhline(np.mean(ham_nve['output/generic/temperature'][-20:]), linestyle='--', color='red') plt.axvline(range(len(ham_nve['output/generic/temperature']))[-20], linestyle='--', color='black') plt.legend() plt.xlabel('timestep') plt.ylabel('Temperature K') plt.legend() plt.show()
Example #10
Source File: interfacemethod.py From pyiron with BSD 3-Clause "New" or "Revised" License | 6 votes |
def check_for_holes(temperature_next, strain_value_lst, nve_run_time_steps, project_parameter, debug_plot=True): max_lst, mean_lst = get_voronoi_volume( temperature_next=temperature_next, strain_lst=strain_value_lst, nve_run_time_steps=nve_run_time_steps, project_parameter=project_parameter ) if debug_plot: plt.plot(strain_value_lst, mean_lst, label='mean') plt.plot(strain_value_lst, max_lst, label='max') plt.axhline(np.mean(mean_lst) * 2, color='black', linestyle='--') plt.legend() plt.xlabel('Strain') plt.ylabel('Voronoi Volume') plt.show() return np.array(max_lst) < np.mean(mean_lst) * 2
Example #11
Source File: plotting_utils.py From nonparaSeq2seqVC_code with MIT License | 6 votes |
def plot_alignment_to_numpy(alignment, info=None): fig, ax = plt.subplots(figsize=(6, 4)) im = ax.imshow(alignment, aspect='auto', origin='lower', interpolation='none') fig.colorbar(im, ax=ax) xlabel = 'Decoder timestep' if info is not None: xlabel += '\n\n' + info plt.xlabel(xlabel) plt.ylabel('Encoder timestep') plt.tight_layout() fig.canvas.draw() data = save_figure_to_numpy(fig) plt.close() return data
Example #12
Source File: efficient_frontier.py From FinQuant with MIT License | 6 votes |
def plot_efrontier(self): """Plots the Efficient Frontier.""" if self.efrontier is None: # compute efficient frontier first self.efficient_frontier() plt.plot( self.efrontier[:, 0], self.efrontier[:, 1], linestyle="-.", color="black", lw=2, label="Efficient Frontier", ) plt.title("Efficient Frontier") plt.xlabel("Volatility") plt.ylabel("Expected Return") plt.legend()
Example #13
Source File: evaluate.py From text-classifier with Apache License 2.0 | 6 votes |
def plot_pr(auc_score, precision, recall, label=None, figure_path=None): """绘制R/P曲线""" try: from matplotlib import pylab pylab.figure(num=None, figsize=(6, 5)) pylab.xlim([0.0, 1.0]) pylab.ylim([0.0, 1.0]) pylab.xlabel('Recall') pylab.ylabel('Precision') pylab.title('P/R (AUC=%0.2f) / %s' % (auc_score, label)) pylab.fill_between(recall, precision, alpha=0.5) pylab.grid(True, linestyle='-', color='0.75') pylab.plot(recall, precision, lw=1) pylab.savefig(figure_path) except Exception as e: print("save image error with matplotlib") pass
Example #14
Source File: utils.py From ndvr-dml with Apache License 2.0 | 6 votes |
def plot_pr_curve(pr_curve_dml, pr_curve_base, title): """ Function that plots the PR-curve. Args: pr_curve: the values of precision for each recall value title: the title of the plot """ plt.figure(figsize=(16, 9)) plt.plot(np.arange(0.0, 1.05, 0.05), pr_curve_base, color='r', marker='o', linewidth=3, markersize=10) plt.plot(np.arange(0.0, 1.05, 0.05), pr_curve_dml, color='b', marker='o', linewidth=3, markersize=10) plt.grid(True, linestyle='dotted') plt.xlabel('Recall', color='k', fontsize=27) plt.ylabel('Precision', color='k', fontsize=27) plt.yticks(color='k', fontsize=20) plt.xticks(color='k', fontsize=20) plt.ylim([0.0, 1.05]) plt.xlim([0.0, 1.0]) plt.title(title, color='k', fontsize=27) plt.tight_layout() plt.show()
Example #15
Source File: plot_kmeans_example.py From Building-Machine-Learning-Systems-With-Python-Second-Edition with MIT License | 6 votes |
def plot_clustering(x, y, title, mx=None, ymax=None, xmin=None, km=None): pylab.figure(num=None, figsize=(8, 6)) if km: pylab.scatter(x, y, s=50, c=km.predict(list(zip(x, y)))) else: pylab.scatter(x, y, s=50) pylab.title(title) pylab.xlabel("Occurrence word 1") pylab.ylabel("Occurrence word 2") pylab.autoscale(tight=True) pylab.ylim(ymin=0, ymax=1) pylab.xlim(xmin=0, xmax=1) pylab.grid(True, linestyle='-', color='0.75') return pylab
Example #16
Source File: benchmark.py From osqp_benchmarks with Apache License 2.0 | 6 votes |
def plot_performance_profiles(problems, solvers): """ Plot performance profiles in matplotlib for specified problems and solvers """ # Remove OSQP polish solver solvers = solvers.copy() for s in solvers: if "polish" in s: solvers.remove(s) df = pd.read_csv('./results/%s/performance_profiles.csv' % problems) plt.figure(0) for solver in solvers: plt.plot(df["tau"], df[solver], label=solver) plt.xlim(1., 10000.) plt.ylim(0., 1.) plt.xlabel(r'Performance ratio $\tau$') plt.ylabel('Ratio of problems solved') plt.xscale('log') plt.legend() plt.grid() plt.show(block=False) results_file = './results/%s/%s.png' % (problems, problems) print("Saving plots to %s" % results_file) plt.savefig(results_file)
Example #17
Source File: plotting_utils.py From nonparaSeq2seqVC_code with MIT License | 6 votes |
def plot_alignment_to_numpy(alignment, info=None): fig, ax = plt.subplots(figsize=(6, 4)) im = ax.imshow(alignment, aspect='auto', origin='lower', interpolation='none') fig.colorbar(im, ax=ax) xlabel = 'Decoder timestep' if info is not None: xlabel += '\n\n' + info plt.xlabel(xlabel) plt.ylabel('Encoder timestep') plt.tight_layout() fig.canvas.draw() data = save_figure_to_numpy(fig) plt.close() return data
Example #18
Source File: kNN.py From statistical-learning-methods-note with Apache License 2.0 | 6 votes |
def plotKChart(self, misClassDict, saveFigPath): kList = [] misRateList = [] for k, misClassNum in misClassDict.iteritems(): kList.append(k) misRateList.append(1.0 - 1.0/k*misClassNum) fig = plt.figure(saveFigPath) plt.plot(kList, misRateList, 'r--') plt.title(saveFigPath) plt.xlabel('k Num.') plt.ylabel('Misclassified Rate') plt.legend(saveFigPath) plt.grid(True) plt.savefig(saveFigPath) plt.show() ################################### PART3 TEST ######################################## # 例子
Example #19
Source File: climatology2.py From incubator-sdap-nexus with Apache License 2.0 | 5 votes |
def histogram(vals, variable, n, outFile): figFile = os.path.splitext(outFile)[0] + '_hist.png' M.clf() # M.hist(vals, 47, (-2., 45.)) M.hist(vals, 94) M.xlim(-5, 45) M.xlabel('SST in degrees Celsius') M.ylim(0, 300000) M.ylabel('Count') M.title('Histogram of %s %d-day Mean from %s' % (variable.upper(), n, outFile)) M.show() print >>sys.stderr, 'Writing histogram plot to %s' % figFile M.savefig(figFile) return figFile
Example #20
Source File: helpers.py From NeMo with Apache License 2.0 | 5 votes |
def plot_alignment_to_numpy(alignment, info=None): fig, ax = plt.subplots(figsize=(6, 4)) im = ax.imshow(alignment, aspect='auto', origin='lower', interpolation='none') fig.colorbar(im, ax=ax) xlabel = 'Decoder timestep' if info is not None: xlabel += '\n\n' + info plt.xlabel(xlabel) plt.ylabel('Encoder timestep') plt.tight_layout() fig.canvas.draw() data = save_figure_to_numpy(fig) plt.close() return data
Example #21
Source File: utils.py From ceviche with MIT License | 5 votes |
def plot_spectral_power(series, dt, f_top=2e14): steps = len(series) freqs, signal_f_power = get_spectral_power(series, dt) # only plot half (other is redundant) plt.plot(freqs[:steps//2], signal_f_power[:steps//2]) plt.xlim([0, f_top]) plt.xlabel('frequency (Hz)') plt.ylabel('power (|signal|^2)') plt.show()
Example #22
Source File: climatology3Spark.py From incubator-sdap-nexus with Apache License 2.0 | 5 votes |
def histogram(vals, variable, n, outFile): figFile = os.path.splitext(outFile)[0] + '_hist.png' M.clf() # M.hist(vals, 47, (-2., 45.)) M.hist(vals, 94) M.xlim(-5, 45) M.xlabel('SST in degrees Celsius') M.ylim(0, 300000) M.ylabel('Count') M.title('Histogram of %s %d-day Mean from %s' % (variable.upper(), n, outFile)) M.show() print >>sys.stderr, 'Writing histogram plot to %s' % figFile M.savefig(figFile) return figFile
Example #23
Source File: plotlib.py From incubator-sdap-nexus with Apache License 2.0 | 5 votes |
def plotVtecAndJasonTracks(gtcFiles, outFile=None, names=None, makeFigure=True, show=False, **options): """Plot GAIM climate and assim VTEC versus JASON using at least two 'gc' files. First file is usually climate file, and rest are assim files. """ ensureItems(options, {'title': 'GAIM vs. JASON for '+gtcFiles[0], \ 'xlabel': 'Geographic Latitude (deg)', 'ylabel': 'VTEC (TECU)'}) if 'show' in options: show = True del options['show'] M.subplot(211) gtcFile = gtcFiles.pop(0) name = 'clim_' if names: name = names.pop(0) specs = [(gtcFile, 'latitude:2,jason:6,gim__:8,%s:13,iri__:10' % name)] name = 'assim' for i, gtcFile in enumerate(gtcFiles): label = name if len(gtcFiles) > 1: label += str(i+1) specs.append( (gtcFile, 'latitude:2,%s:13' % label) ) plotColumns(specs, rmsDiffFrom='jason', floatFormat='%5.1f', **options) M.legend() M.subplot(212) options.update({'title': 'JASON Track Plot', 'xlabel': 'Longitude (deg)', 'ylabel': 'Latitude (deg)'}) fields = N.array([map(floatOrMiss, line.split()) for line in open(gtcFiles[0], 'r')]) lons = fields[:,2]; lats = fields[:,1] marksOnMap(lons, lats, show=show, **options) if outFile: M.savefig(outFile)
Example #24
Source File: BirthMoveTopicModel.py From refinery with MIT License | 5 votes |
def viz_deletion_sidebyside(model, rmodel, ELBO, rELBO, block=False): from ..viz import BarsViz from matplotlib import pylab pylab.figure() h=pylab.subplot(1,2,1) BarsViz.plotBarsFromHModel(model, figH=h) h=pylab.subplot(1,2,2) BarsViz.plotBarsFromHModel(rmodel, figH=h) pylab.xlabel("%.3e" % (rELBO - ELBO)) pylab.show(block=block)
Example #25
Source File: plotting.py From melgan with BSD 3-Clause "New" or "Revised" License | 5 votes |
def plot_waveform_to_numpy(waveform): fig, ax = plt.subplots(figsize=(12, 3)) ax.plot() ax.plot(range(len(waveform)), waveform, linewidth=0.1, alpha=0.7, color='blue') plt.xlabel("Samples") plt.ylabel("Amplitude") plt.ylim(-1, 1) plt.tight_layout() fig.canvas.draw() data = save_figure_to_numpy(fig) plt.close() return data
Example #26
Source File: mode_solver.py From modesolverpy with MIT License | 5 votes |
def _plot_n_effs(self, filename_n_effs, filename_te_fractions, xlabel, ylabel, title): args = { "titl": title, "xlab": xlabel, "ylab": ylabel, "filename_data": filename_n_effs, "filename_frac_te": filename_te_fractions, "filename_image": None, "num_modes": len(self.modes), } filename_image_prefix, _ = os.path.splitext(filename_n_effs) filename_image = filename_image_prefix + ".png" args["filename_image"] = filename_image if MPL: data = np.loadtxt(args["filename_data"], delimiter=",").T plt.clf() plt.title(title) plt.xlabel(args["xlab"]) plt.ylabel(args["ylab"]) for i in range(args["num_modes"]): plt.plot(data[0], data[i + 1], "-o") plt.savefig(args["filename_image"]) else: gp.gnuplot(self._path + "n_effs.gpi", args, silent=False) gp.trim_pad_image(filename_image) return args
Example #27
Source File: plotting_utils.py From nonparaSeq2seqVC_code with MIT License | 5 votes |
def plot_spectrogram_to_numpy(spectrogram): fig, ax = plt.subplots(figsize=(12, 3)) im = ax.imshow(spectrogram, aspect="auto", origin="lower", interpolation='none') plt.colorbar(im, ax=ax) plt.xlabel("Frames") plt.ylabel("Channels") plt.tight_layout() fig.canvas.draw() data = save_figure_to_numpy(fig) plt.close() return data
Example #28
Source File: plotting_utils.py From nonparaSeq2seqVC_code with MIT License | 5 votes |
def plot_gate_outputs_to_numpy(gate_targets, gate_outputs): fig, ax = plt.subplots(figsize=(12, 3)) ax.scatter(list(range(len(gate_targets))), gate_targets, alpha=0.5, color='green', marker='+', s=1, label='target') ax.scatter(list(range(len(gate_outputs))), gate_outputs, alpha=0.5, color='red', marker='.', s=1, label='predicted') plt.xlabel("Frames (Green target, Red predicted)") plt.ylabel("Gate State") plt.tight_layout() fig.canvas.draw() data = save_figure_to_numpy(fig) plt.close() return data
Example #29
Source File: plotting_utils.py From nonparaSeq2seqVC_code with MIT License | 5 votes |
def plot_spectrogram_to_numpy(spectrogram): fig, ax = plt.subplots(figsize=(12, 3)) im = ax.imshow(spectrogram, aspect="auto", origin="lower", interpolation='none') plt.colorbar(im, ax=ax) plt.xlabel("Frames") plt.ylabel("Channels") plt.tight_layout() fig.canvas.draw() data = save_figure_to_numpy(fig) plt.close() return data
Example #30
Source File: mode_solver.py From modesolverpy with MIT License | 5 votes |
def _plot_fraction( self, filename_fraction, xlabel, ylabel, title, mode_list=[] ): if not mode_list: mode_list = range(len(self.modes)) gp_mode_list = " ".join(str(idx) for idx in mode_list) args = { "titl": title, "xlab": xlabel, "ylab": ylabel, "filename_data": filename_fraction, "filename_image": None, "mode_list": gp_mode_list, } filename_image_prefix, _ = os.path.splitext(filename_fraction) filename_image = filename_image_prefix + ".png" args["filename_image"] = filename_image if MPL: data = np.loadtxt(args["filename_data"], delimiter=",").T plt.clf() plt.title(title) plt.xlabel(args["xlab"]) plt.ylabel(args["ylab"]) for i, _ in enumerate(self.modes): plt.plot(data[0], data[i + 1], "-o") plt.savefig(args["filename_image"]) else: gp.gnuplot(self._path + "fractions.gpi", args, silent=False) gp.trim_pad_image(filename_image) return args