當前位置: 首頁>>代碼示例>>Python>>正文


Python pyplot.errorbar方法代碼示例

本文整理匯總了Python中matplotlib.pyplot.errorbar方法的典型用法代碼示例。如果您正苦於以下問題:Python pyplot.errorbar方法的具體用法?Python pyplot.errorbar怎麽用?Python pyplot.errorbar使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在matplotlib.pyplot的用法示例。


在下文中一共展示了pyplot.errorbar方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: plot_abnormal_cumulative_return_with_errors

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import errorbar [as 別名]
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() 
開發者ID:santiment,項目名稱:sanpy,代碼行數:22,代碼來源:event_study.py

示例2: plot_gap

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import errorbar [as 別名]
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() 
開發者ID:canard0328,項目名稱:malss,代碼行數:22,代碼來源:clustering.py

示例3: quad_fit

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import errorbar [as 別名]
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() 
開發者ID:annayqho,項目名稱:TheCannon,代碼行數:18,代碼來源:snr_test.py

示例4: example1

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import errorbar [as 別名]
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() 
開發者ID:aewallin,項目名稱:allantools,代碼行數:25,代碼來源:gradev-demo.py

示例5: test_errorbar_shape

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import errorbar [as 別名]
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') 
開發者ID:holzschu,項目名稱:python3_ios,代碼行數:18,代碼來源:test_axes.py

示例6: errorbars

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import errorbar [as 別名]
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() 
開發者ID:KarchinLab,項目名稱:2020plus,代碼行數:19,代碼來源:plot.py

示例7: plot_metric

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import errorbar [as 別名]
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) 
開發者ID:alexlee-gk,項目名稱:video_prediction,代碼行數:20,代碼來源:plot_results.py

示例8: update_errorbar

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import errorbar [as 別名]
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) 
開發者ID:mcgillmrl,項目名稱:kusanagi,代碼行數:20,代碼來源:utils_.py

示例9: calib_plot

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import errorbar [as 別名]
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) 
開發者ID:MGensheimer,項目名稱:nnet-survival,代碼行數:24,代碼來源:support_study.py

示例10: plot_lds_results

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import errorbar [as 別名]
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() 
開發者ID:HIPS,項目名稱:pgmult,代碼行數:19,代碼來源:multinomial_lds_2.py

示例11: plot_graph

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import errorbar [as 別名]
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) 
開發者ID:RUBi-ZA,項目名稱:MD-TASK,代碼行數:22,代碼來源:avg_network.py

示例12: matplotlib

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import errorbar [as 別名]
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() 
開發者ID:scikit-hep,項目名稱:uproot-methods,代碼行數:20,代碼來源:TGraphAsymmErrors.py

示例13: plot

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import errorbar [as 別名]
def plot(self, show=True, fpath=None):
        f = plt.figure()
        for d in self.data:
            fmt = (self.color_to_str.get(d['color'], '') +
                   self.line_type_to_str.get(d['line_type'], ''))
            plt.errorbar(d['xs'],
                         d['ys'],
                         yerr=d['err'],
                         label=d['label'],
                         fmt=fmt)

        if self.title is not None:
            plt.title(self.title)
        if self.xlabel is not None:
            plt.xlabel(self.xlabel)
        if self.ylabel is not None:
            plt.ylabel(self.ylabel)

        if any([d['label'] is not None for d in self.data]):
            plt.legend(loc='best')

        if fpath is not None:
            f.savefig(fpath, bbox_inches='tight')
        if show:
            plt.show()
        return f 
開發者ID:negrinho,項目名稱:deep_architect,代碼行數:28,代碼來源:visualization.py

示例14: fit_plot_central_charge

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import errorbar [as 別名]
def fit_plot_central_charge(s_list, xi_list, filename):
    """Plot routine in order to determine the cental charge."""
    import matplotlib.pyplot as plt
    from scipy.optimize import curve_fit

    def fitFunc(Xi, c, a):
        return (c / 6) * np.log(Xi) + a

    Xi = np.array(xi_list)
    S = np.array(s_list)
    LXi = np.log(Xi)  # Logarithm of the correlation length xi

    fitParams, fitCovariances = curve_fit(fitFunc, Xi, S)

    # Plot fitting parameter and covariances
    print('c =', fitParams[0], 'a =', fitParams[1])
    print('Covariance Matrix', fitCovariances)

    # plot the data as blue circles
    plt.errorbar(LXi,
                 S,
                 fmt='o',
                 c='blue',
                 ms=5.5,
                 markerfacecolor='white',
                 markeredgecolor='blue',
                 markeredgewidth=1.4)
    # plot the fitted line
    plt.plot(LXi,
             fitFunc(Xi, fitParams[0], fitParams[1]),
             linewidth=1.5,
             c='black',
             label='fit c={c:.2f}'.format(c=fitParams[0]))

    plt.xlabel(r'$\log{\,}\xi_{\chi}$', fontsize=16)
    plt.ylabel(r'$S$', fontsize=16)
    plt.legend(loc='lower right', borderaxespad=0., fancybox=True, shadow=True, fontsize=16)
    plt.savefig(filename) 
開發者ID:tenpy,項目名稱:tenpy,代碼行數:40,代碼來源:central_charge_ising.py

示例15: plot

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import errorbar [as 別名]
def plot(base, regex, criterion, retrieve_list):
    keys = map(int_or_float, [a.split('/')[-1] for a in glob.glob(base + '*')])
    means, std_devs = {}, {}
    for i, key in enumerate(keys):
        pattern = base + str(key) + regex
        answer = find_best(pattern, criterion, retrieve_list)
        if answer[0] is not None:
            means[key], std_devs[key] = answer
    plot_keys = sorted(means.keys())
    means = np.asarray([means[key] for key in plot_keys])
    std_devs = np.asarray([std_devs[key] for key in plot_keys])
    (_, caps, _) = plt.errorbar(plot_keys, means, yerr=1.96*std_devs,
                                marker='o', markersize=5, capsize=5)
    for cap in caps:
        cap.set_markeredgewidth(1) 
開發者ID:AshishBora,項目名稱:csgm,代碼行數:17,代碼來源:metrics_utils.py


注:本文中的matplotlib.pyplot.errorbar方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。