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


Python pyplot.vlines方法代碼示例

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


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

示例1: time_ph

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import vlines [as 別名]
def time_ph(d, i=0, num_ph=1e4, ph_istart=0):
    """Plot 'num_ph' ph starting at 'ph_istart' marking burst start/end.
    TODO: Update to use the new matplotlib eventplot.
    """
    b = d.mburst[i]
    SLICE = slice(ph_istart, ph_istart+num_ph)
    ph_d = d.ph_times_m[i][SLICE][~d.A_em[i][SLICE]]
    ph_a = d.ph_times_m[i][SLICE][d.A_em[i][SLICE]]

    BSLICE = (b.stop < ph_a[-1])
    start, end = b[BSLICE].start, b[BSLICE].stop

    u = d.clk_p # time scale
    plt.vlines(ph_d*u, 0, 1, color='k', alpha=0.02)
    plt.vlines(ph_a*u, 0, 1, color='k', alpha=0.02)
    plt.vlines(start*u, -0.5, 1.5, lw=3, color=green, alpha=0.5)
    plt.vlines(end*u, -0.5, 1.5, lw=3, color=red, alpha=0.5)
    xlabel("Time (s)")


##
#  Histogram plots
# 
開發者ID:tritemio,項目名稱:FRETBursts,代碼行數:25,代碼來源:burst_plot.py

示例2: test_scheduler

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import vlines [as 別名]
def test_scheduler(self):
        epochs = 10

        max_lr = 3e-3
        alpha = 1e-2

        steps_per_epoch = 1024 
        scheduler = optim.WarmupCosineDecayLRScheduler(
            max_lr,
            steps_per_epoch, 
            (steps_per_epoch * (epochs - 1)), alpha=alpha)

        lrs = [scheduler(i) for i in range(epochs * steps_per_epoch)]
        epoch_ends_at = [i * steps_per_epoch for i in range(epochs)]

        print('Last lr', lrs[-1])

        plt.plot(range(epochs * steps_per_epoch), lrs)
        plt.vlines(epoch_ends_at, 0, max_lr)
        plt.show(block=True) 
開發者ID:Guillem96,項目名稱:efficientdet-tf,代碼行數:22,代碼來源:scheduler_test.py

示例3: plot_1d

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import vlines [as 別名]
def plot_1d(self,filename=None):
        """plot the 1d insertion representation of the matrix"""
        fig = plt.figure()
        xlim = len(self.one_d)/2
        plt.plot(range(-xlim,xlim+1),self.one_d)
        plt.vlines(-73,0,max(self.one_d)*1.1,linestyles='dashed')
        plt.vlines(73,0,max(self.one_d)*1.1,linestyles='dashed')
        plt.xlabel("Position relative to dyad")
        plt.ylabel("Insertion Frequency")
        if filename:
            fig.savefig(filename)
            plt.close(fig)
            #Also save text output!
            filename2 = ".".join(filename.split(".")[:-1]+['txt'])
            np.savetxt(filename2,self.one_d,delimiter="\t")
        else:
            fig.show() 
開發者ID:GreenleafLab,項目名稱:NucleoATAC,代碼行數:19,代碼來源:VMat.py

示例4: plotting_proc

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import vlines [as 別名]
def plotting_proc(self, g):
        """
        For internal use
        """
        survival = self.results[g][0]
        t = self.ts[g]
        e = (self.event)[g]
        if self.censoring != None:
            c = self.censorings[g]
            csurvival = survival[c != 0]
            ct = t[c != 0]
            if len(ct) != 0:
                plt.vlines(ct,csurvival+0.02,csurvival-0.02)
        x = np.repeat(t[e != 0], 2)
        y = np.repeat(survival[e != 0], 2)
        if self.ts[g][-1] in t[e != 0]:
            x = np.r_[0,x]
            y = np.r_[1,1,y[:-1]]
        else:
            x = np.r_[0,x,self.ts[g][-1]]
            y = np.r_[1,1,y]
        plt.plot(x,y) 
開發者ID:nccgroup,項目名稱:Splunking-Crime,代碼行數:24,代碼來源:survival2.py

示例5: plot_knee

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import vlines [as 別名]
def plot_knee(self, figsize: Optional[Tuple[int, int]] = None):
        """
        Plot the curve and the knee, if it exists

        :param figsize: Optional[Tuple[int, int]
            The figure size of the plot. Example (12, 8)
        :return: NoReturn
        """
        import matplotlib.pyplot as plt

        if figsize is None:
            figsize = (6, 6)

        plt.figure(figsize=figsize)
        plt.title("Knee Point")
        plt.plot(self.x, self.y, "b", label="data")
        plt.vlines(
            self.knee, plt.ylim()[0], plt.ylim()[1], linestyles="--", label="knee/elbow"
        )
        plt.legend(loc="best")

    # Niceties for users working with elbows rather than knees 
開發者ID:arvkevi,項目名稱:kneed,代碼行數:24,代碼來源:knee_locator.py

示例6: draw_violin_sdr

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import vlines [as 別名]
def draw_violin_sdr(json_folder):
    acc, voc = compute_mean_metrics(json_folder, compute_averages=False)
    acc = acc[~np.isnan(acc)]
    voc = voc[~np.isnan(voc)]
    data = [acc, voc]
    inds = [1,2]

    fig, ax = plt.subplots()
    ax.violinplot(data, showmeans=True, showmedians=False, showextrema=False, vert=False)
    ax.scatter(np.percentile(data, 50, axis=1),inds, marker="o", color="black")
    ax.set_title("Segment-wise SDR distribution")
    ax.vlines([np.min(acc), np.min(voc), np.max(acc), np.max(voc)], [0.8, 1.8, 0.8, 1.8], [1.2, 2.2, 1.2, 2.2], color="blue")
    ax.hlines(inds, [np.min(acc), np.min(voc)], [np.max(acc), np.max(voc)], color='black', linestyle='--', lw=1, alpha=0.5)

    ax.set_yticks([1,2])
    ax.set_yticklabels(["Accompaniment", "Vocals"])

    fig.set_size_inches(8, 3.)
    fig.savefig("sdr_histogram.pdf", bbox_inches='tight') 
開發者ID:f90,項目名稱:Wave-U-Net,代碼行數:21,代碼來源:Plot.py

示例7: run_all_benchmarks

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import vlines [as 別名]
def run_all_benchmarks(method='forward', order=4, x_values=(0.1, 0.5, 1.0, 5), n_max=11,
                       show_plot=True):

    epsilon = MinStepGenerator(num_steps=3, scale=None, step_nom=None)
    scales = {}
    for n in range(1, n_max):
        plt.figure(n)
        scale_n = scales.setdefault(n, [])
        # for (name, x) in itertools.product( function_names, x_values):
        for name in function_names:
            fun0, dfun = get_function(name, n)
            if dfun is None:
                continue
            fd = Derivative(fun0, step=epsilon, method=method, n=n, order=order)
            for x in x_values:
                r = benchmark(x=x, dfun=dfun, fd=fd, name=name, scales=None, show_plot=show_plot)
                print(r)
                scale = r['scale']
                if np.isfinite(scale):
                    scale_n.append(scale)

        plt.vlines(np.mean(scale_n), 1e-12, 1, 'r', linewidth=3)
        plt.vlines(np.median(scale_n), 1e-12, 1, 'b', linewidth=3)

    _print_summary(method, order, x_values, scales) 
開發者ID:pbrod,項目名稱:numdifftools,代碼行數:27,代碼來源:_find_default_scale.py

示例8: plotSpectre

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import vlines [as 別名]
def plotSpectre(transitions, eneval, spectre):
    """ plot the UV-visible spectrum using matplotlib. Absissa are converted in nm. """

    # lambda in nm
    lambdaval = [cst.h * cst.c / (val * cst.e) * 1.e9 for val in eneval]

    # plot gaussian spectra
    plt.plot(lambdaval, spectre, "r-", label = "spectre")

    # plot transitions
    plt.vlines([val[1] for val in transitions], \
               0., \
               [val[2] for val in transitions], \
               color = "blue", \
               label = "transitions" )

    plt.xlabel("lambda   /   nm")
    plt.ylabel("Arbitrary unit")
    plt.title("UV-visible spectra")
    plt.grid()
    plt.legend(fancybox = True, shadow = True)
    plt.show() 
開發者ID:gVallverdu,項目名稱:myScripts,代碼行數:24,代碼來源:spectre.py

示例9: plot_knee

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import vlines [as 別名]
def plot_knee(self, ):
        font1 = {'family' : 'STXihei',
                 'weight' : 'normal',
                 'size'   : 50,
                 }
        """Plot the curve and the knee, if it exists"""
        import matplotlib.pyplot as plt

        plt.figure(figsize=(8*3, 8*3))
        plt.plot(self.x, self.y,'ro-',label="建設用地聚類最大總數")
        plt.xlabel('聚類距離',font1)
#        plt.ylabel('POI獨立點',font1)
        plt.ylabel('聚類最大總數',font1)
        plt.tick_params(labelsize=40)
        plt.legend(prop=font1)

#        plt.axis["right"].set_visible(False)
#        plt.axis["top"].set_visible(False)
        plt.vlines(self.knee, plt.ylim()[0], plt.ylim()[1],colors='black')

    # Niceties for users working with elbows rather than knees 
開發者ID:richieBao,項目名稱:python-urbanPlanning,代碼行數:23,代碼來源:knee_locator.py

示例10: plot_knee

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import vlines [as 別名]
def plot_knee(self, ):
        font1 = {'family' : 'STXihei',
                 'weight' : 'normal',
                 'size'   : 50,
                 }
        """Plot the curve and the knee, if it exists"""
        import matplotlib.pyplot as plt

        plt.figure(figsize=(8*3, 8*3))
        plt.plot(self.x, self.y,'ro-',label="POI聚類總數")
        plt.xlabel('聚類距離',font1)
#        plt.ylabel('POI獨立點',font1)
        plt.ylabel('聚類總數',font1)
        plt.tick_params(labelsize=40)
        plt.legend(prop=font1)

#        plt.axis["right"].set_visible(False)
#        plt.axis["top"].set_visible(False)
        plt.vlines(self.knee, plt.ylim()[0], plt.ylim()[1],colors='black')

    # Niceties for users working with elbows rather than knees 
開發者ID:richieBao,項目名稱:python-urbanPlanning,代碼行數:23,代碼來源:knee_locator.py

示例11: binom_pmf

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import vlines [as 別名]
def binom_pmf(n=1, p=0.1):
    """
    二項分布有兩個參數
    https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.binom.html#scipy.stats.binom
    :param n:試驗次數
    :param p:單次實驗成功的概率
    :return:
    """
    binom_dis = stats.binom(n, p)
    x = np.arange(binom_dis.ppf(0.0001), binom_dis.ppf(0.9999))
    print(x)  # [ 0.  1.  2.  3.  4.]
    fig, ax = plt.subplots(1, 1)
    ax.plot(x, binom_dis.pmf(x), 'bo', label='binom pmf')
    ax.vlines(x, 0, binom_dis.pmf(x), colors='b', lw=5, alpha=0.5)
    ax.legend(loc='best', frameon=False)
    plt.ylabel('Probability')
    plt.title('PMF of binomial distribution(n={}, p={})'.format(n, p))
    plt.show()

# binom_pmf(n=20, p=0.6) 
開發者ID:OnlyBelter,項目名稱:machine-learning-note,代碼行數:22,代碼來源:draw_pmf.py

示例12: poisson_pmf

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import vlines [as 別名]
def poisson_pmf(mu=3):
    """
    泊鬆分布
    https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.poisson.html#scipy.stats.poisson
    :param mu: 單位時間(或單位麵積)內隨機事件的平均發生率
    :return:
    """
    poisson_dis = stats.poisson(mu)
    x = np.arange(poisson_dis.ppf(0.001), poisson_dis.ppf(0.999))
    print(x)
    fig, ax = plt.subplots(1, 1)
    ax.plot(x, poisson_dis.pmf(x), 'bo', ms=8, label='poisson pmf')
    ax.vlines(x, 0, poisson_dis.pmf(x), colors='b', lw=5, alpha=0.5)
    ax.legend(loc='best', frameon=False)
    plt.ylabel('Probability')
    plt.title('PMF of poisson distribution(mu={})'.format(mu))
    plt.show()

# poisson_pmf(mu=8) 
開發者ID:OnlyBelter,項目名稱:machine-learning-note,代碼行數:21,代碼來源:draw_pmf.py

示例13: custom_made_discrete_dis_pmf

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import vlines [as 別名]
def custom_made_discrete_dis_pmf():
    """
    https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.rv_discrete.html
    :return:
    """
    xk = np.arange(7)  # 所有可能的取值
    print(xk)  # [0 1 2 3 4 5 6]
    pk = (0.1, 0.2, 0.3, 0.1, 0.1, 0.0, 0.2)  # 各個取值的概率
    custm = stats.rv_discrete(name='custm', values=(xk, pk))

    X = custm.rvs(size=20)
    print(X)

    fig, ax = plt.subplots(1, 1)
    ax.plot(xk, custm.pmf(xk), 'ro', ms=8, mec='r')
    ax.vlines(xk, 0, custm.pmf(xk), colors='r', linestyles='-', lw=2)
    plt.title('Custom made discrete distribution(PMF)')
    plt.ylabel('Probability')
    plt.show()

# custom_made_discrete_dis_pmf() 
開發者ID:OnlyBelter,項目名稱:machine-learning-note,代碼行數:23,代碼來源:draw_pmf.py

示例14: plot_vertical_line

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import vlines [as 別名]
def plot_vertical_line(x, y, binEdges, linestyles="dashed", colors="k"):
    plt.vlines(x, 0, np.interp(x, binEdges, y), linestyles=linestyles, colors=colors) 
開發者ID:robcarver17,項目名稱:systematictradingexamples,代碼行數:4,代碼來源:whichriskappetite.py

示例15: Vlines

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import vlines [as 別名]
def Vlines(xs, y1, y2, **options):
    """Plots a set of vertical lines.

    Args:
      xs: sequence of x values
      y1: sequence of y values
      y2: sequence of y values
      options: keyword args passed to plt.vlines
    """
    options = _UnderrideColor(options)
    options = _Underride(options, linewidth=1, alpha=0.5)
    plt.vlines(xs, y1, y2, **options) 
開發者ID:Notabela,項目名稱:Lie_to_me,代碼行數:14,代碼來源:thinkplot.py


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