本文整理匯總了Python中matplotlib.pyplot.axvline方法的典型用法代碼示例。如果您正苦於以下問題:Python pyplot.axvline方法的具體用法?Python pyplot.axvline怎麽用?Python pyplot.axvline使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類matplotlib.pyplot
的用法示例。
在下文中一共展示了pyplot.axvline方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _hist_burst_taildist
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import axvline [as 別名]
def _hist_burst_taildist(data, bins, pdf, weights=None, yscale='log',
color=None, label=None, plot_style=None, vline=None):
hist = HistData(*np.histogram(data[~np.isnan(data)],
bins=_bins_array(bins), weights=weights))
ydata = hist.pdf if pdf else hist.counts
default_plot_style = dict(marker='o')
if plot_style is None:
plot_style = {}
if color is not None:
plot_style['color'] = color
if label is not None:
plot_style['label'] = label
default_plot_style.update(_normalize_kwargs(plot_style, kind='line2d'))
plt.plot(hist.bincenters, ydata, **default_plot_style)
if vline is not None:
plt.axvline(vline, ls='--')
plt.yscale(yscale)
if pdf:
plt.ylabel('PDF')
else:
plt.ylabel('# Bursts')
示例2: dosplot
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import axvline [as 別名]
def dosplot (filename = None, data = None, fermi = None):
if (filename is not None): data = np.loadtxt(filename)
elif (data is not None): data = data
import matplotlib.pyplot as plt
from matplotlib import rc
plt.rc('text', usetex=True)
plt.rc('font', family='serif')
plt.plot(data.T[0], data.T[1], label='MF Spin-UP', linestyle=':',color='r')
plt.fill_between(data.T[0], 0, data.T[1], facecolor='r',alpha=0.1, interpolate=True)
plt.plot(data.T[0], data.T[2], label='QP Spin-UP',color='r')
plt.fill_between(data.T[0], 0, data.T[2], facecolor='r',alpha=0.5, interpolate=True)
plt.plot(data.T[0],-data.T[3], label='MF Spin-DN', linestyle=':',color='b')
plt.fill_between(data.T[0], 0, -data.T[3], facecolor='b',alpha=0.1, interpolate=True)
plt.plot(data.T[0],-data.T[4], label='QP Spin-DN',color='b')
plt.fill_between(data.T[0], 0, -data.T[4], facecolor='b',alpha=0.5, interpolate=True)
if (fermi!=None): plt.axvline(x=fermi ,color='k', linestyle='--') #label='Fermi Energy'
plt.axhline(y=0,color='k')
plt.title('Total DOS', fontsize=20)
plt.xlabel('Energy (eV)', fontsize=15)
plt.ylabel('Density of States (electron/eV)', fontsize=15)
plt.legend()
plt.savefig("dos_eigen.svg", dpi=900)
plt.show()
示例3: plot_gap
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import axvline [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()
示例4: plot_silhouette
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import axvline [as 別名]
def plot_silhouette(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("Silhouette score")
plt.plot(range(algorithm.results['min_nc'], algorithm.results['max_nc'] + 1),
algorithm.results['silhouette'], 'o-', color='darkorange')
plt.axvline(x=algorithm.results['silhouette_nc'], ls='--', C='gray', zorder=0)
plt.savefig('%s/silhouette_%s.png' %
(dname, algorithm.estimator.__class__.__name__),
bbox_inches='tight', dpi=75)
plt.close()
示例5: plot_davies
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import axvline [as 別名]
def plot_davies(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("Davies-Bouldin score")
plt.plot(range(algorithm.results['min_nc'], algorithm.results['max_nc'] + 1),
algorithm.results['davies'], 'o-', color='limegreen')
plt.axvline(x=algorithm.results['davies_nc'], ls='--', C='gray', zorder=0)
plt.savefig('%s/davies_%s.png' %
(dname, algorithm.estimator.__class__.__name__),
bbox_inches='tight', dpi=75)
plt.close()
示例6: plot_calinski
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import axvline [as 別名]
def plot_calinski(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("Calinski and Harabasz score")
plt.plot(range(algorithm.results['min_nc'], algorithm.results['max_nc'] + 1),
algorithm.results['calinski'], 'o-', color='crimson')
plt.axvline(x=algorithm.results['calinski_nc'], ls='--', C='gray', zorder=0)
plt.savefig('%s/calinski_%s.png' %
(dname, algorithm.estimator.__class__.__name__),
bbox_inches='tight', dpi=75)
plt.close()
示例7: chisq_dist
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import axvline [as 別名]
def chisq_dist():
fig = plt.figure(figsize=(6,4))
ivar = np.load("%s/val_ivar_norm.npz" %DATA_DIR)['arr_0']
npix = np.sum(ivar>0, axis=1)
chisq = np.load("%s/val_chisq.npz" %DATA_DIR)['arr_0']
redchisq = chisq/npix
nbins = 25
plt.hist(redchisq, bins=nbins, color='k', histtype="step",
lw=2, normed=False, alpha=0.3, range=(0,3))
plt.legend()
plt.xlabel("Reduced $\chi^2$", fontsize=16)
plt.tick_params(axis='both', labelsize=16)
plt.ylabel("Count", fontsize=16)
plt.axvline(x=1.0, linestyle='--', c='k')
fig.tight_layout()
#plt.show()
plt.savefig("chisq_dist.png")
示例8: plot_rss
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import axvline [as 別名]
def plot_rss(cm, t1, t2, t3):
"""Plot the memory profile."""
f = plt.figure(figsize=(8, 6))
plt.plot(range(cm.cpu.shape[0]), cm.rss / 1000000)
plt.axvline(t1 - 3, color='darkcyan', linestyle='--', linewidth=1.0,
label='load data')
plt.axvline(t2, color='blue', linestyle='--', linewidth=1.0,
label='fit start')
plt.axvline(t3, color='blue', linestyle='-.', linewidth=1.0,
label='fit end')
plt.xticks([i for i in [0, 50, 100, 150, 200, 250]],
[i for i in [0, 5, 10, 15, 20, 25]])
# plt.ylim(120, 240)
plt.title("ML-Ensemble memory profile (working set)")
plt.ylabel("Working set memory (MB)")
plt.xlabel("Time (s)")
plt.legend()
plt.show()
if PRINT:
try:
f.savefig("dev/img/memory_profile.png", dpi=600)
except:
f.savefig("memory_profile.png", dpi=600)
示例9: plot_cpu
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import axvline [as 別名]
def plot_cpu(cm, t1, t2, t3):
"""Plot the CPU profile."""
f = plt.figure()
plt.plot(range(cm.cpu.shape[0]), cm.cpu)
plt.axvline(t1 - 3, color='darkcyan', linestyle='--', linewidth=1.0,
label='load data')
plt.axvline(t2, color='blue', linestyle='--', linewidth=1.0,
label='fit start')
plt.axvline(t3, color='blue', linestyle='-.', linewidth=1.0,
label='fit end')
plt.xticks([i for i in [0, 50, 100, 150, 200, 250]],
[i for i in [0, 5, 10, 15, 20, 25]])
plt.title("ML-Ensemble CPU profile")
plt.ylabel("CPU utilization (%)")
plt.xlabel("Time (s)")
plt.legend()
if PRINT:
try:
f.savefig("dev/cpu_profile.png", dpi=600)
except:
f.savefig("cpu_profile.png", dpi=600)
示例10: plot_histogram_matrix
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import axvline [as 別名]
def plot_histogram_matrix(data, name, fname=None):
# local import to avoid dependency for non-debug use
import matplotlib.pyplot as plt
nhists = len(data[0])
nbins = 25
ylim = (0, 0.5)
nrows = int(np.ceil(np.sqrt(nhists)))
plt.figure(figsize=(nrows * 4, nrows * 4))
for i in range(nhists):
plt.subplot(nrows, nrows, i + 1)
absmax = max(abs(np.max(data[:, i])), abs(np.min(data[:, i])))
rng = (-absmax, absmax)
h, bins = np.histogram(data[:, i], nbins, rng)
bin_width = bins[1] - bins[0]
h = h.astype("float32") / np.sum(h)
plt.bar(bins[:-1], h, bin_width)
plt.axvline(np.mean(data[:, i]), color="red")
plt.ylim(ylim)
plt.title("{:s}[{:d}]".format(name, i))
if fname is None:
plt.show()
else:
plt.savefig(fname)
plt.close()
示例11: data_visualization
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import axvline [as 別名]
def data_visualization(co_price, pcb_price):
"""
原始數據可視化
"""
x_co_values = co_price.index
y_co_values = co_price.price / 100
x_pcb_values = pcb_price.index
y_pcb_values = pcb_price.price
plt.figure(figsize=(10, 6))
plt.title('copper price(100rmb/t) vs. pcb price(rmb/sq.m.)')
plt.xlabel('date')
plt.ylabel('history price')
plt.plot(x_co_values, y_co_values, '-', label='co price')
plt.plot(x_pcb_values, y_pcb_values, '-', label='pcb price')
plt.axvline('2015-04-23', linewidth=1, color='r', linestyle='dashed')
plt.axvline('2015-10-23', linewidth=1, color='r', linestyle='dashed')
plt.axvline('2016-04-23', linewidth=1, color='r', linestyle='dashed')
plt.axvline('2016-10-23', linewidth=1, color='r', linestyle='dashed')
plt.legend(loc='upper right')
plt.show()
示例12: plot_fermi_dirac
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import axvline [as 別名]
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
示例13: plot_polarization_ratio
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import axvline [as 別名]
def plot_polarization_ratio(polarization_ratio, plotName, labels,
number_of_quantiles):
"""
Generate a plot to visualize the polarization ratio between A and B
compartments. It presents how well 2 compartments are seperated.
"""
for i, r in enumerate(polarization_ratio):
plt.plot(r, marker="o", label=labels[i])
plt.axhline(1, c='grey', ls='--', lw=1)
plt.axvline(number_of_quantiles / 2, c='grey', ls='--', lw=1)
plt.legend(loc='best')
plt.xlabel('Quantiles')
plt.ylabel('signal within comp. / signla between comp.')
plt.title('compartment polarization ratio')
plt.savefig(plotName)
示例14: plotGPGO
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import axvline [as 別名]
def plotGPGO(gpgo, param, index, new=True):
param_value = list(param.values())[0][1]
x_test = np.linspace(param_value[0], param_value[1], 1000).reshape((1000, 1))
y_hat, y_var = gpgo.GP.predict(x_test, return_std=True)
std = np.sqrt(y_var)
l, u = y_hat - 1.96 * std, y_hat + 1.96 * std
if new:
plt.figure()
plt.subplot(5, 1, 1)
plt.fill_between(x_test.flatten(), l, u, alpha=0.2)
plt.plot(x_test.flatten(), y_hat)
plt.subplot(5, 1, index)
a = np.array([-gpgo._acqWrapper(np.atleast_1d(x)) for x in x_test]).flatten()
plt.plot(x_test, a, color=colors[index - 2], label=acq_titles[index - 2])
gpgo._optimizeAcq(method='L-BFGS-B', n_start=1000)
plt.axvline(x=gpgo.best)
plt.legend(loc=0)
示例15: plotGPGO
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import axvline [as 別名]
def plotGPGO(gpgo, param):
param_value = list(param.values())[0][1]
x_test = np.linspace(param_value[0], param_value[1], 1000).reshape((1000, 1))
hat = gpgo.GP.predict(x_test, return_std=True)
y_hat, y_std = hat[0], np.sqrt(hat[1])
l, u = y_hat - 1.96 * y_std, y_hat + 1.96 * y_std
fig = plt.figure()
r = fig.add_subplot(2, 1, 1)
r.set_title('Fitted Gaussian process')
plt.fill_between(x_test.flatten(), l, u, alpha=0.2)
plt.plot(x_test.flatten(), y_hat, color='red', label='Posterior mean')
plt.legend(loc=0)
a = np.array([-gpgo._acqWrapper(np.atleast_1d(x)) for x in x_test]).flatten()
r = fig.add_subplot(2, 1, 2)
r.set_title('Acquisition function')
plt.plot(x_test, a, color='green')
gpgo._optimizeAcq(method='L-BFGS-B', n_start=1000)
plt.axvline(x=gpgo.best, color='black', label='Found optima')
plt.legend(loc=0)
plt.tight_layout()
plt.savefig(os.path.join(os.getcwd(), 'mthesis_text/figures/chapter3/sine/{}.pdf'.format(i)))
plt.show()