本文整理汇总了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
#
示例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)
示例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()
示例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)
示例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
示例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')
示例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)
示例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()
示例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
示例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
示例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)
示例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)
示例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()
示例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)
示例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)