Python matplotlib.pyplot.errorbar() Examples
The following are 30
code examples of matplotlib.pyplot.errorbar().
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.pyplot
, or try the search function
.
Example #1
Source File: event_study.py From sanpy with MIT License | 6 votes |
def plot_abnormal_cumulative_return_with_errors(abnormal_volatility, abnormal_returns, events): """ Capturing volatility of abnormal returns """ pyplot.figure(figsize=FIGURE_SIZE) pyplot.errorbar( abnormal_returns.index, abnormal_returns, xerr=0, yerr=abnormal_volatility, label="events=%s" % events ) pyplot.grid(b=None, which=u'major', axis=u'y') pyplot.title("Abnormal Cumulative Return from Events with error") pyplot.xlabel("Window Length (t)") pyplot.ylabel("Cumulative Return (r)") pyplot.legend() pyplot.show()
Example #2
Source File: snr_test.py From TheCannon with MIT License | 6 votes |
def quad_fit(x, y, yerr, name, unit): """ Fit a qudratic to the SNR to make a lookup error table """ print("performing quad fit") qfit = np.polyfit(x, y, deg=2, w = 1 / yerr) print(qfit) plt.figure() #plt.scatter(x, y) plt.errorbar(x, y, yerr=yerr, fmt='.', c='k') xvals = np.linspace(min(x), max(x), 100) print(xvals) yvals = qfit[2] + qfit[1]*xvals + qfit[0]*xvals**2 print(yvals) plt.plot(xvals, yvals, color='r', lw=2) plt.xlabel("%s" %snr_label, fontsize=16) plt.ylabel(r"$\sigma %s \mathrm{(%s)}$" %(name,unit), fontsize=16) plt.show()
Example #3
Source File: clustering.py From malss with MIT License | 6 votes |
def plot_gap(cls, algorithm, dname): if dname is None: return if not os.path.exists(dname): os.mkdir(dname) plt.figure() plt.title(algorithm.estimator.__class__.__name__) plt.xlabel("Number of clusters") plt.ylabel("Gap statistic") plt.plot(range(algorithm.results['min_nc'], algorithm.results['max_nc'] + 1), algorithm.results['gap'], 'o-', color='dodgerblue') plt.errorbar(range(algorithm.results['min_nc'], algorithm.results['max_nc'] + 1), algorithm.results['gap'], algorithm.results['gap_sk'], capsize=3) plt.axvline(x=algorithm.results['gap_nc'], ls='--', C='gray', zorder=0) plt.savefig('%s/gap_%s.png' % (dname, algorithm.estimator.__class__.__name__), bbox_inches='tight', dpi=75) plt.close()
Example #4
Source File: TGraphAsymmErrors.py From uproot-methods with BSD 3-Clause "New" or "Revised" License | 6 votes |
def matplotlib(self, showtitle=True, show=False, **kwargs): import matplotlib.pyplot as pyplot _xerrs = [self.xerrorslow, self.xerrorshigh] _yerrs = [self.yerrorslow, self.yerrorshigh] _xlabel = _decode(self.xlabel if self.xlabel is not None else "") _ylabel = _decode(self.ylabel if self.ylabel is not None else "") pyplot.errorbar(self.xvalues, self.yvalues, xerr=_xerrs, yerr=_yerrs, **kwargs) pyplot.xlabel(_xlabel) pyplot.ylabel(_ylabel) if showtitle: _title = _decode(self.title) pyplot.title(_title) if show: pyplot.show()
Example #5
Source File: multinomial_lds_2.py From pgmult with MIT License | 6 votes |
def plot_lds_results(X, z_mean, z_std, pis): # Plot the true and inferred states plt.figure() ax1 = plt.subplot(311) plt.errorbar(z_mean[:,0], color="r", yerr=z_std[:,0]) plt.errorbar(z_mean[:,1], ls="--", color="r", yerr=z_std[:,1]) ax1.set_title("True and inferred latent states") ax2 = plt.subplot(312) plt.imshow(X.T, interpolation="none", vmin=0, vmax=1, cmap="Blues") ax2.set_title("Observed counts") ax4 = plt.subplot(313) N_samples = pis.shape[0] plt.imshow(pis[N_samples//2:,...].mean(0).T, interpolation="none", vmin=0, vmax=1, cmap="Blues") ax4.set_title("Mean inferred probabilities") plt.show()
Example #6
Source File: support_study.py From nnet-survival with MIT License | 6 votes |
def calib_plot(fu_time, n_bins, pred_surv, time, dead, color, label, error_bars=0,alpha=1., markersize=1., markertype='o'): cuts = np.concatenate((np.array([-1e6]),np.percentile(pred_surv, np.arange(100/n_bins,100,100/n_bins)),np.array([1e6]))) bin = pd.cut(pred_surv,cuts,labels=False) kmf = KaplanMeierFitter() est = [] ci_upper = [] ci_lower = [] mean_pred_surv = [] for which_bin in range(max(bin)+1): kmf.fit(time[bin==which_bin], event_observed=dead[bin==which_bin]) est.append(np.interp(fu_time, kmf.survival_function_.index.values, kmf.survival_function_.KM_estimate)) ci_upper.append(np.interp(fu_time, kmf.survival_function_.index.values, kmf.confidence_interval_.loc[:,'KM_estimate_upper_0.95'])) ci_lower.append(np.interp(fu_time, kmf.survival_function_.index.values, kmf.confidence_interval_.loc[:,'KM_estimate_lower_0.95'])) mean_pred_surv.append(np.mean(pred_surv[bin==which_bin])) est = np.array(est) ci_upper = np.array(ci_upper) ci_lower = np.array(ci_lower) if error_bars: plt.errorbar(mean_pred_surv, est, yerr = np.transpose(np.column_stack((est-ci_lower,ci_upper-est))), fmt='o',c=color,label=label) else: plt.plot(mean_pred_surv, est, markertype, c=color,label=label, alpha=alpha, markersize=markersize) return (mean_pred_surv, est)
Example #7
Source File: gradev-demo.py From allantools with GNU Lesser General Public License v3.0 | 6 votes |
def example1(): """ Compute the GRADEV of a white phase noise. Compares two different scenarios. 1) The original data and 2) ADEV estimate with gap robust ADEV. """ N = 1000 f = 1 y = np.random.randn(1,N)[0,:] x = [xx for xx in np.linspace(1,len(y),len(y))] x_ax, y_ax, (err_l, err_h), ns = allan.gradev(y,data_type='phase',rate=f,taus=x) plt.errorbar(x_ax, y_ax,yerr=[err_l,err_h],label='GRADEV, no gaps') y[int(np.floor(0.4*N)):int(np.floor(0.6*N))] = np.NaN # Simulate missing data x_ax, y_ax, (err_l, err_h) , ns = allan.gradev(y,data_type='phase',rate=f,taus=x) plt.errorbar(x_ax, y_ax,yerr=[err_l,err_h], label='GRADEV, with gaps') plt.xscale('log') plt.yscale('log') plt.grid() plt.legend() plt.xlabel('Tau / s') plt.ylabel('Overlapping Allan deviation') plt.show()
Example #8
Source File: utils_.py From kusanagi with MIT License | 6 votes |
def update_errorbar(errobj, x, y, y_error): # from http://stackoverflow.com/questions/25210723/matplotlib-set-data-for-errorbar-plot ln, (erry_top, erry_bot), (barsy,) = errobj ln.set_xdata(x) ln.set_ydata(y) x_base = x y_base = y yerr_top = y_base + y_error yerr_bot = y_base - y_error erry_top.set_xdata(x_base) erry_bot.set_xdata(x_base) erry_top.set_ydata(yerr_top) erry_bot.set_ydata(yerr_bot) new_segments_y = [np.array([[x, yt], [x,yb]]) for x, yt, yb in zip(x_base, yerr_top, yerr_bot)] barsy.set_segments(new_segments_y)
Example #9
Source File: plot_results.py From video_prediction with MIT License | 6 votes |
def plot_metric(metric, start_x=0, color=None, label=None, zorder=None): import matplotlib.pyplot as plt metric_mean = np.mean(metric, axis=0) metric_se = np.std(metric, axis=0) / np.sqrt(len(metric)) kwargs = {} if color: kwargs['color'] = color if zorder: kwargs['zorder'] = zorder plt.errorbar(np.arange(len(metric_mean)) + start_x, metric_mean, yerr=metric_se, linewidth=2, label=label, **kwargs) # metric_std = np.std(metric, axis=0) # plt.plot(np.arange(len(metric_mean)) + start_x, metric_mean, # linewidth=2, color=color, label=label) # plt.fill_between(np.arange(len(metric_mean)) + start_x, # metric_mean - metric_std, metric_mean + metric_std, # color=color, alpha=0.5)
Example #10
Source File: plot.py From 2020plus with Apache License 2.0 | 6 votes |
def errorbars(x, y, err, save_path='', title='', xlabel='', ylabel='', label=''): if label: plt.errorbar(x, y, yerr=err, label=label, fmt='-o') plt.legend(loc='best') else: plt.errorbar(x, y, yerr=err, fmt='-o') plt.title(title) plt.xlabel(xlabel) plt.ylabel(ylabel) if save_path: plt.savefig(save_path) plt.close()
Example #11
Source File: avg_network.py From MD-TASK with GNU General Public License v3.0 | 6 votes |
def plot_graph(network, err=None, start_x=1, color="black", ecolor="red", title="Title", x_label="X", y_label="Y", ylim=None): start_x = int(start_x) num_nodes = network.shape[0] nodes_axis = range(start_x, num_nodes + start_x) plt.axhline(0, color='black') if err is not None: plt.errorbar(nodes_axis, network, err, color="black", ecolor="red") else: plt.plot(nodes_axis, network, color="black") if ylim: axes = plt.gca() axes.set_ylim(ylim) plt.title(title, fontsize=18) plt.xlabel(x_label, fontsize=16) plt.ylabel(y_label, fontsize=16)
Example #12
Source File: test_axes.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_errorbar_shape(): fig = plt.figure() ax = fig.gca() x = np.arange(0.1, 4, 0.5) y = np.exp(-x) yerr1 = 0.1 + 0.2*np.sqrt(x) yerr = np.vstack((yerr1, 2*yerr1)).T xerr = 0.1 + yerr with pytest.raises(ValueError): ax.errorbar(x, y, yerr=yerr, fmt='o') with pytest.raises(ValueError): ax.errorbar(x, y, xerr=xerr, fmt='o') with pytest.raises(ValueError): ax.errorbar(x, y, yerr=yerr, xerr=xerr, fmt='o')
Example #13
Source File: improved_mi_interpret_results.py From EvaluatingDPML with MIT License | 5 votes |
def plot_accuracy(result): train_accs, baseline_acc = np.zeros(B), np.zeros(B) for run in RUNS: aux, membership, per_instance_loss, yeom_mi_outputs_1, yeom_mi_outputs_2, proposed_mi_outputs = result['no_privacy'][run] train_loss, train_acc, test_loss, test_acc = aux baseline_acc[run] = test_acc train_accs[run] = train_acc baseline_acc = np.mean(baseline_acc) print(np.mean(train_accs), baseline_acc) color = 0.1 y = dict() for dp in DP: test_acc_vec = np.zeros((A, B)) for a, eps in enumerate(EPSILONS): mi_1_zero_m, mi_1_zero_nm, mi_2_zero_m, mi_2_zero_nm = [], [], [], [] for run in RUNS: aux, membership, per_instance_loss, yeom_mi_outputs_1, yeom_mi_outputs_2, proposed_mi_outputs = result[dp][eps][run] train_loss, train_acc, test_loss, test_acc = aux test_acc_vec[a, run] = test_acc y[dp] = 1 - np.mean(test_acc_vec, axis=1) / baseline_acc plt.errorbar(EPSILONS, y[dp], yerr=np.std(test_acc_vec, axis=1), color=str(color), fmt='.-', capsize=2, label=DP_LABELS[DP.index(dp)]) color += 0.2 plt.xscale('log') plt.xlabel('Privacy Budget ($\epsilon$)') plt.ylabel('Accuracy Loss') plt.yticks(np.arange(0, 1.1, step=0.2)) plt.annotate("RDP", pretty_position(EPSILONS, y["rdp_"], 2), textcoords="offset points", xytext=(20, 10), ha='right', color=str(0.3)) plt.annotate("GDP", pretty_position(EPSILONS, y["gdp_"], 2), textcoords="offset points", xytext=(-20, -10), ha='right', color=str(0.1)) plt.tight_layout() plt.show()
Example #14
Source File: examples.py From Numpy_arraysetops_EP with MIT License | 5 votes |
def test_radial_reduction(): """radial reduction example""" x = np.linspace(-2,2, 64) y = x[:, None] x = x[None, :] R = np.sqrt(x**2+y**2) def airy(r, sigma): from scipy.special import j1 r = r / sigma * np.sqrt(2) a = (2*j1(r)/r)**2 a[r==0] = 1 return a def gauss(r, sigma): return np.exp(-(r/sigma)**2) distribution = np.random.choice([gauss, airy])(R, 0.3) sample = np.random.poisson(distribution*200+10).astype(np.float) #is this an airy or gaussian function? hard to tell with all this noise! plt.imshow(sample, interpolation='nearest', cmap='gray') plt.show() #radial reduction to the rescue! #if we are sampling an airy function, you will see a small but significant rise around x=1 g = group_by(np.round(R, 5).flatten()) plt.errorbar( g.unique, g.mean(sample.flatten())[1], g.std (sample.flatten())[1] / np.sqrt(g.count)) plt.xlim(0, 2) plt.show()
Example #15
Source File: __init__.py From radvel with MIT License | 5 votes |
def telplot(x, y, e, tel, ax, lw=1., telfmt={}, rms=0): """Plot data from from a single telescope x (array): Either time or phase y (array): RV e (array): RV error tel (string): telecsope string key ax (matplotlib.axes.Axes): current Axes object lw (float): line-width for error bars telfmt (dict): dictionary corresponding to kwargs passed to errorbar. Example: telfmt = dict(fmt='o',label='HIRES',color='red') """ # Default formatting kw = dict( fmt='o', capsize=0, mew=0, ecolor='0.6', lw=lw, color='orange', ) # If not explicit format set, look among default formats if not telfmt and tel in telfmts_default: telfmt = telfmts_default[tel] for k in telfmt: kw[k] = telfmt[k] if not 'label' in kw.keys(): if tel in telfmts_default: kw['label'] = telfmts_default[tel]['label'] else: kw['label'] = tel if rms: kw['label'] += '\nRMS={:.2f} {:s}'.format(rms, latex['ms']) pl.errorbar(x, y, yerr=e, **kw)
Example #16
Source File: analysis.py From velocyto.py with BSD 2-Clause "Simplified" License | 5 votes |
def plot_fractions(self, save2file: str=None) -> None: """Plots a barplot showing the abundance of spliced/unspliced molecules in the dataset Arguments --------- save2file: str (default: None) If not None specifies the file path to which plots get saved Returns ------- Nothing, it plots a barplot """ plt.figure(figsize=(3.2, 5)) try: chips, chip_ix = np.unique(self.ca["SampleID"], return_inverse=1) except KeyError: chips, chip_ix = np.unique([i.split(":")[0] for i in self.ca["CellID"]], return_inverse=1) n = len(chips) for i in np.unique(chip_ix): tot_mol_cell_submatrixes = [X[:, chip_ix == i].sum(0) for X in [self.S, self.A, self.U]] total = np.sum(tot_mol_cell_submatrixes, 0) _mean = [np.mean(j / total) for j in tot_mol_cell_submatrixes] _std = [np.std(j / total) for j in tot_mol_cell_submatrixes] plt.ylabel("Fraction") plt.bar(np.linspace(-0.2, 0.2, n)[i] + np.arange(3), _mean, 0.5 / (n * 1.05), label=chips[i]) plt.errorbar(np.linspace(-0.2, 0.2, n)[i] + np.arange(3), _mean, _std, c="k", fmt="none", lw=1, capsize=2) # Hide the right and top spines plt.gca().spines['right'].set_visible(False) plt.gca().spines['top'].set_visible(False) # Only show ticks on the left and bottom spines plt.gca().yaxis.set_ticks_position('left') plt.gca().xaxis.set_ticks_position('bottom') plt.gca().spines['left'].set_bounds(0, 0.8) plt.legend() plt.xticks(np.arange(3), ["spliced", "ambiguous", "unspliced"]) plt.tight_layout() if save2file: plt.savefig(save2file, bbox_inches="tight")
Example #17
Source File: test_axes.py From ImageFusion with MIT License | 5 votes |
def test_eb_line_zorder(): x = list(xrange(10)) # First illustrate basic pyplot interface, using defaults where possible. fig = plt.figure() ax = fig.gca() ax.plot(x, lw=10, zorder=5) ax.axhline(1, color='red', lw=10, zorder=1) ax.axhline(5, color='green', lw=10, zorder=10) ax.axvline(7, color='m', lw=10, zorder=7) ax.axvline(2, color='k', lw=10, zorder=3) ax.set_title("axvline and axhline zorder test") # Now switch to a more OO interface to exercise more features. fig = plt.figure() ax = fig.gca() x = list(xrange(10)) y = np.zeros(10) yerr = list(xrange(10)) ax.errorbar(x, y, yerr=yerr, zorder=5, lw=5, color='r') for j in range(10): ax.axhline(j, lw=5, color='k', zorder=j) ax.axhline(-j, lw=5, color='k', zorder=j) ax.set_title("errorbar zorder test")
Example #18
Source File: test_axes.py From ImageFusion with MIT License | 5 votes |
def test_errorbar(): x = np.arange(0.1, 4, 0.5) y = np.exp(-x) yerr = 0.1 + 0.2*np.sqrt(x) xerr = 0.1 + yerr # First illustrate basic pyplot interface, using defaults where possible. fig = plt.figure() ax = fig.gca() ax.errorbar(x, y, xerr=0.2, yerr=0.4) ax.set_title("Simplest errorbars, 0.2 in x, 0.4 in y") # Now switch to a more OO interface to exercise more features. fig, axs = plt.subplots(nrows=2, ncols=2, sharex=True) ax = axs[0, 0] ax.errorbar(x, y, yerr=yerr, fmt='o') ax.set_title('Vert. symmetric') # With 4 subplots, reduce the number of axis ticks to avoid crowding. ax.locator_params(nbins=4) ax = axs[0, 1] ax.errorbar(x, y, xerr=xerr, fmt='o', alpha=0.4) ax.set_title('Hor. symmetric w/ alpha') ax = axs[1, 0] ax.errorbar(x, y, yerr=[yerr, 2*yerr], xerr=[xerr, 2*xerr], fmt='--o') ax.set_title('H, V asymmetric') ax = axs[1, 1] ax.set_yscale('log') # Here we have to be careful to keep all y values positive: ylower = np.maximum(1e-2, y - yerr) yerr_lower = y - ylower ax.errorbar(x, y, yerr=[yerr_lower, 2*yerr], xerr=xerr, fmt='o', ecolor='g', capthick=2) ax.set_title('Mixed sym., log y') fig.suptitle('Variable errorbars')
Example #19
Source File: plotting.py From snn_toolbox with MIT License | 5 votes |
def plot_param_sweep(results, n, params, param_name, param_logscale): """Plot accuracy versus parameter. Parameters ---------- results: list[float] The accuracy or loss for a number of experiments, each of which used different parameters. n: int The number of test samples used for each experiment. params: list[float] The parameter values that changed during each experiment. param_name: str The name of the parameter that varied. param_logscale: bool Whether to plot the parameter axis in log-scale. """ # Compute confidence intervals of the experiments ci = [wilson_score(q, n) for q in results] if param_logscale: plt.xscale('log', nonposx='clip') plt.errorbar(params, results, yerr=ci, fmt='x-') plt.title('Accuracy vs Hyperparameter') plt.xlabel(param_name) plt.ylabel('accuracy') fac = 0.9 if params[0] < 0: fac += 0.2 plt.xlim(fac * params[0], 1.1 * params[-1]) plt.ylim(0, 1)
Example #20
Source File: plots.py From deep_architect_legacy with MIT License | 5 votes |
def plot_performance_quantiles(): folder_path = 'logs/searcher_comparison' searchers = ['rand', 'mcts', 'mcts_bi', 'smbo'] search_space_type = 'deepconv' num_repeats = 5 for searcher_type in searchers: # load all the pickles rs = [] for i in xrange(num_repeats): file_name = '%s_%s_%d.pkl' % (search_space_type, searcher_type, i) file_path = os.path.join(folder_path, file_name) with open(file_path, 'rb') as f: r = pickle.load(f) rs.append(r) percents = np.linspace(0.0, 1.0, num=100) srch_scores = [compute_percentiles(r['scores'], percents) for r in rs] mean = np.mean(srch_scores, axis=0) std = np.std(srch_scores, axis=0) plt.errorbar(percents, mean, yerr=std / np.sqrt(num_repeats), label=searcher_type) plt.legend(loc='best') plt.xlabel('Validation performance') plt.ylabel('Fraction of models better or equal') #plt.title('') # plt.axis([0, 64, 0.6, 1.0]) # plt.show() plt.savefig(figs_folderpath + 'quants.pdf', bbox_inches='tight') plt.close()
Example #21
Source File: typeI_analysis.py From SAMPL6 with MIT License | 5 votes |
def plot_correlation_with_SEM(x_lab, y_lab, x_err_lab, y_err_lab, data, title=None, color=None, ax=None): # Extract only pKa values. x_error = data.loc[:, x_err_lab] y_error = data.loc[:, y_err_lab] x_values = data.loc[:, x_lab] y_values = data.loc[:, y_lab] data = data[[x_lab, y_lab]] # Find extreme values to make axes equal. min_limit = np.ceil(min(data.min()) - 2) max_limit = np.floor(max(data.max()) + 2) axes_limits = np.array([min_limit, max_limit]) # Color current_palette = sns.color_palette() sns_blue = current_palette[0] # Plot plt.figure(figsize=(6, 6)) grid = sns.regplot(x=x_values, y=y_values, data=data, color=color, ci=None) plt.errorbar(x=x_values, y=y_values, xerr=x_error, yerr=y_error, fmt="o", ecolor=sns_blue, capthick='2', label='SEM', alpha=0.75) plt.axis("equal") if len(title) > 70: plt.title(title[:70]+"...") else: plt.title(title) # Add diagonal line. grid.plot(axes_limits, axes_limits, ls='--', c='black', alpha=0.8, lw=0.7) # Add shaded area for 0.5-1 pKa error. palette = sns.color_palette('BuGn_r') grid.fill_between(axes_limits, axes_limits - 0.5, axes_limits + 0.5, alpha=0.2, color=palette[2]) grid.fill_between(axes_limits, axes_limits - 1, axes_limits + 1, alpha=0.2, color=palette[3]) plt.xlim(axes_limits) plt.ylim(axes_limits)
Example #22
Source File: logP_analysis.py From SAMPL6 with MIT License | 5 votes |
def plot_correlation_with_SEM(x_lab, y_lab, x_err_lab, y_err_lab, data, title=None, color=None, ax=None): # Extract only logP values. x_error = data.loc[:, x_err_lab] y_error = data.loc[:, y_err_lab] x_values = data.loc[:, x_lab] y_values = data.loc[:, y_lab] data = data[[x_lab, y_lab]] # Find extreme values to make axes equal. min_limit = np.ceil(min(data.min()) - 1) max_limit = np.floor(max(data.max()) + 1) axes_limits = np.array([min_limit, max_limit]) # Color current_palette = sns.color_palette() sns_blue = current_palette[0] # Plot plt.figure(figsize=(6, 6)) grid = sns.regplot(x=x_values, y=y_values, data=data, color=color, ci=None) plt.errorbar(x=x_values, y=y_values, xerr=x_error, yerr=y_error, fmt="o", ecolor=sns_blue, capthick='2', label='SEM', alpha=0.75) plt.axis("equal") if len(title) > 70: plt.title(title[:70]+"...") else: plt.title(title) # Add diagonal line. grid.plot(axes_limits, axes_limits, ls='--', c='black', alpha=0.8, lw=0.7) # Add shaded area for 0.5-1 logP error. palette = sns.color_palette('BuGn_r') grid.fill_between(axes_limits, axes_limits - 0.5, axes_limits + 0.5, alpha=0.2, color=palette[2]) grid.fill_between(axes_limits, axes_limits - 1, axes_limits + 1, alpha=0.2, color=palette[3]) plt.xlim(axes_limits) plt.ylim(axes_limits)
Example #23
Source File: graphEvaluation.py From TikZ with GNU General Public License v3.0 | 5 votes |
def plotBernoulli(d,f): global MAXIMUMY d = [ [ (1 if z == 1 else 0) for z in d[x] ] for x in xs ] y = [average(z) for z in d ] e = [ bernoulliStandardError(z) for z in d ] plot.errorbar(xs,y,fmt = f,yerr = e) MAXIMUMY = max(y + [MAXIMUMY])
Example #24
Source File: logP_analysis.py From SAMPL6 with MIT License | 5 votes |
def plot_correlation_with_SEM(x_lab, y_lab, x_err_lab, y_err_lab, data, title=None, color=None, ax=None): # Extract only logP values. x_error = data.loc[:, x_err_lab] y_error = data.loc[:, y_err_lab] x_values = data.loc[:, x_lab] y_values = data.loc[:, y_lab] data = data[[x_lab, y_lab]] # Find extreme values to make axes equal. min_limit = np.ceil(min(data.min()) - 1) max_limit = np.floor(max(data.max()) + 1) axes_limits = np.array([min_limit, max_limit]) # Color current_palette = sns.color_palette() sns_blue = current_palette[0] # Plot plt.figure(figsize=(6, 6)) grid = sns.regplot(x=x_values, y=y_values, data=data, color=color, ci=None) plt.errorbar(x=x_values, y=y_values, xerr=x_error, yerr=y_error, fmt="o", ecolor=sns_blue, capthick='2', label='SEM', alpha=0.75) plt.axis("equal") if len(title) > 70: plt.title(title[:70]+"...") else: plt.title(title) # Add diagonal line. grid.plot(axes_limits, axes_limits, ls='--', c='black', alpha=0.8, lw=0.7) # Add shaded area for 0.5-1 logP error. palette = sns.color_palette('BuGn_r') grid.fill_between(axes_limits, axes_limits - 0.5, axes_limits + 0.5, alpha=0.2, color=palette[2]) grid.fill_between(axes_limits, axes_limits - 1, axes_limits + 1, alpha=0.2, color=palette[3]) plt.xlim(axes_limits) plt.ylim(axes_limits)
Example #25
Source File: benchmark_plot.py From pyFileFixity with MIT License | 5 votes |
def kind_plot(test, kind): sizes = sorted(data[test][kind].keys()) yrange = [[(data[test][kind][size][5] - data[test][kind][size][3]) for size in sizes], [(data[test][kind][size][4] - data[test][kind][size][5]) for size in sizes]] # Timer isn't any better than micro-second resolution. yvalues = [max(1e-6, data[test][kind][size][5]) for size in sizes] plt.errorbar(sizes, yvalues, yerr=yrange)
Example #26
Source File: test_axes.py From coffeegrindsize with MIT License | 5 votes |
def test_errorbar_colorcycle(): f, ax = plt.subplots() x = np.arange(10) y = 2*x e1, _, _ = ax.errorbar(x, y, c=None) e2, _, _ = ax.errorbar(x, 2*y, c=None) ln1, = ax.plot(x, 4*y) assert mcolors.to_rgba(e1.get_color()) == mcolors.to_rgba('C0') assert mcolors.to_rgba(e2.get_color()) == mcolors.to_rgba('C1') assert mcolors.to_rgba(ln1.get_color()) == mcolors.to_rgba('C2')
Example #27
Source File: event_study.py From sanpy with MIT License | 5 votes |
def plot_cumulative_return_with_errors(returns, std_devs, events): """ Plotting the same graph but with error bars """ pyplot.figure(figsize=FIGURE_SIZE) pyplot.errorbar(returns.index, returns, xerr=0, yerr=std_devs, label="events=%s" % events) pyplot.grid(b=None, which=u'major', axis=u'y') pyplot.title("Cumulative Return from Events with error") pyplot.xlabel("Window Length (t)") pyplot.ylabel("Cumulative Return (r)") pyplot.legend() pyplot.show()
Example #28
Source File: utils.py From pyprocessmacro with MIT License | 5 votes |
def plot_errorbars( x, y, yerrlow, yerrhigh, plot_kws=None, err_kws=None, *args, **kwargs ): yerr = [yerrlow, yerrhigh] err_kws_final = kwargs.copy() err_kws_final.update(err_kws) err_kws_final.update({"marker": "", "fmt": "none", "label": "", "zorder": 3}) plot_kws_final = kwargs.copy() plot_kws_final.update(plot_kws) plt.plot(x, y, *args, **plot_kws_final) plt.errorbar(x, y, yerr, *args, **err_kws_final) return None
Example #29
Source File: test_legend.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_fancy(): # using subplot triggers some offsetbox functionality untested elsewhere plt.subplot(121) plt.scatter(np.arange(10), np.arange(10, 0, -1), label='XX\nXX') plt.plot([5] * 10, 'o--', label='XX') plt.errorbar(np.arange(10), np.arange(10), xerr=0.5, yerr=0.5, label='XX') plt.legend(loc="center left", bbox_to_anchor=[1.0, 0.5], ncol=2, shadow=True, title="My legend", numpoints=1)
Example #30
Source File: graphEvaluation.py From TikZ with GNU General Public License v3.0 | 5 votes |
def plotAverages(d,f): global MAXIMUMY y = [average(d[x]) for x in xs ] e = [standardError(d[x]) for x in xs ] plot.errorbar(xs,y,fmt = f,yerr = e) MAXIMUMY = max(y + [MAXIMUMY])