本文整理汇总了Python中matplotlib.pyplot.axhline方法的典型用法代码示例。如果您正苦于以下问题:Python pyplot.axhline方法的具体用法?Python pyplot.axhline怎么用?Python pyplot.axhline使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.pyplot
的用法示例。
在下文中一共展示了pyplot.axhline方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: dosplot
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import axhline [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()
示例2: add_horizontal_lines
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import axhline [as 别名]
def add_horizontal_lines(data, events, x_key, y_key, rotation=0):
max_x = max(data[x_key])
min_x = min(data[x_key])
ratio_positive = math.fabs(min_x)/(math.fabs(min_x)+math.fabs(max_x))
for key in events:
if events[key] is not None:
if events[key] >= len(data[x_key]):
continue
if np.sign(data[x_key][events[key]]) > 0:
xmin = ratio_positive
xmax = 1
x = 0.65*max_x
else:
xmin = 0
xmax = ratio_positive
x = min_x
plt.text(x, data[y_key][int(events[key])], events_to_text[key], fontsize=15, rotation=rotation)
plt.axhline(y=data[y_key][int(events[key])], xmin=xmin, xmax=xmax, color='black', linestyle='--')
示例3: plot_polarization_ratio
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import axhline [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)
示例4: plot_MNIST_results
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import axhline [as 别名]
def plot_MNIST_results():
matplotlib.rcParams.update({'font.size': 10})
fig = plt.figure(figsize=(6,4), dpi=100)
ll_1hl = [-92.17,-90.69,-89.86,-89.16,-88.61,-88.25,-87.95,-87.71]
ll_2hl = [-89.17, -87.96, -87.10, -86.41, -85.96, -85.60, -85.28, -85.10]
x = np.arange(len(ll_1hl))
plt.axhline(y=-84.55, color="black", linestyle="--", label="2hl-DBN")
plt.axhline(y=-86.34, color="black", linestyle="-.", label="RBM")
plt.axhline(y=-88.33, color="black", linestyle=":", label="NADE (fixed order)")
plt.plot(ll_1hl, "r^-", label="1hl-NADE")
plt.plot(ll_2hl, "go-", label="2hl-NADE")
plt.xticks(x, 2**x)
plt.xlabel("Models averaged")
plt.ylabel("Test loglikelihood (nats)")
plt.legend(loc=4, prop = {"size":10})
plt.subplots_adjust(left=0.12, right=0.95, top=0.97, bottom=0.10)
plt.savefig(os.path.join(DESTINATION_PATH, "likelihoodvsorderings.pdf"))
示例5: behavior
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import axhline [as 别名]
def behavior(Behavior):
from numpy import polyfit, poly1d
# Plotting Tbottom and Tout through time
time = Behavior.time
tbot_smooth = polyfit(time, Behavior.tbot, 14)
tbot = poly1d(tbot_smooth)(time)
plt.plot(time, tbot, 'r', label='Bottom (Tubing)') # Temp. outlet vs Time
plt.axhline(y=Behavior.tfm[-1], color='k', label='Formation') # Formation Temp. vs Time
plt.xlim(0, Behavior.finaltime)
plt.xlabel('Time, h')
plt.ylabel('Temperature, °C')
title = 'Temperature behavior (%1.1f hours)' % Behavior.finaltime
plt.title(title)
plt.legend() # applying the legend
plt.show()
示例6: behavior
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import axhline [as 别名]
def behavior(Behavior):
"""
Plotting Tbottom and Tout through time
"""
from numpy import polyfit, poly1d
time = Behavior.time
tbot_smooth = polyfit(time, Behavior.tbot, 14)
tbot = poly1d(tbot_smooth)(time)
tout_smooth = polyfit(time, Behavior.tout, 14)
tout = poly1d(tout_smooth)(time)
plt.plot(time, tbot, 'b', label='Bottom') # Temp. inside Annulus vs Time
plt.plot(time, tout, 'r', label='Outlet (Annular)') # Temp. inside Annulus vs Time
plt.axhline(y=Behavior.tfm[-1], color='k', label='Formation') # Formation Temp. vs Time
plt.xlim(0, Behavior.finaltime)
plt.xlabel('Time, h')
plt.ylabel('Temperature, °C')
title = 'Temperature behavior (%1.1f hours)' % Behavior.finaltime
plt.title(title)
plt.legend() # applying the legend
plt.show()
示例7: behavior
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import axhline [as 别名]
def behavior(Behavior):
from numpy import polyfit, poly1d
# Plotting Tbottom and Tout through time
time = Behavior.time
tout_smooth = polyfit(time, Behavior.tout, 10)
tout = poly1d(tout_smooth)(time)
plt.plot(time, tout, 'r', label='Outlet (Tubing)') # Temp. outlet vs Time
plt.axhline(y=Behavior.tfm[-1], color='k', label='Formation') # Formation Temp. vs Time
plt.xlim(0, Behavior.finaltime)
plt.xlabel('Time, h')
plt.ylabel('Temperature, °C')
title = 'Temperature behavior (%1.1f hours)' % Behavior.finaltime
plt.title(title)
plt.legend() # applying the legend
plt.grid()
plt.show()
示例8: plot_graph
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import axhline [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)
示例9: threshold_plotter_generator
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import axhline [as 别名]
def threshold_plotter_generator(self):
"""
Generates a plotter to visualize when the signal is above the set threshold
Returns:
function: Plots the threshold with the current continuous waveform
"""
import matplotlib
matplotlib.use('TkAgg')
plt.figure(figsize=(10, 2))
plt.axhline(y=self.threshold, xmin=0.0, xmax=1.0, color='r')
plt.axhline(y=-self.threshold, xmin=0.0, xmax=1.0, color='r')
plt.pause(0.000000000001)
def threshold_plotter(data):
plt.clf()
plt.tight_layout()
plt.axis([0, len(data), -20000, 20000])
plt.plot(data, color='b')
plt.axhline(y=self.threshold, xmin=0.0, xmax=1.0, color='r')
plt.axhline(y=-self.threshold, xmin=0.0, xmax=1.0, color='r')
plt.pause(0.000000000001)
return threshold_plotter
示例10: plot
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import axhline [as 别名]
def plot(hdiff, title):
""" Plots the solar return hour distance to
anniversary using matplotlib.
"""
import matplotlib.pyplot as plt
years = [elem[0] for elem in hdiff]
hours = [elem[1] for elem in hdiff]
plt.plot(years, hours)
plt.ylabel('Hour distance')
plt.xlabel('Year')
plt.title(title)
plt.axhline(y=-24, c='red')
plt.show()
# Set the birth date and time
示例11: plot
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import axhline [as 别名]
def plot(hdiff, title):
""" Plots the tropical solar length
by year.
"""
import matplotlib.pyplot as plt
years = [elem[0] for elem in hdiff]
diffs = [elem[1] for elem in hdiff]
plt.plot(years, diffs)
plt.ylabel('Distance in minutes')
plt.xlabel('Year')
plt.title(title)
plt.axhline(y=0, c='red')
plt.show()
# Set the starting year
示例12: plot_dos_phonopy
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import axhline [as 别名]
def plot_dos_phonopy(self, force_constants=None):
phonopy_dos = pho_interface.obtain_phonopy_dos(self.dynamic.structure,
mesh=self.parameters.mesh_phonopy,
projected_on_atom=self.parameters.project_on_atom,
NAC=self.parameters.use_NAC)
plt.plot(phonopy_dos[0], phonopy_dos[1], 'b-', label='Harmonic')
if force_constants is not None:
phonopy_dos_r = pho_interface.obtain_phonopy_dos(self.dynamic.structure,
mesh=self.parameters.mesh_phonopy,
force_constants=force_constants,
projected_on_atom=self.parameters.project_on_atom,
NAC=self.parameters.use_NAC)
plt.plot(phonopy_dos_r[0], phonopy_dos_r[1], 'g-', label='Renormalized')
plt.title('Density of states (Normalized to unit cell)')
plt.xlabel('Frequency [THz]')
plt.ylabel('Density of states')
plt.legend()
plt.axhline(y=0, color='k', ls='dashed')
plt.show()
示例13: plot_autocorrelation
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import axhline [as 别名]
def plot_autocorrelation(chain, interval=2, max_lag=100, radius=1.1):
if max_lag is None:
max_lag = chain.size()
autocorrelations = chain.autocorrelations()[:max_lag]
lags = np.arange(0, max_lag, interval)
autocorrelations = autocorrelations[lags]
plt.ylim([-radius, radius])
center = .5
for index, lag in enumerate(lags):
autocorrelation = autocorrelations[index]
plt.axvline(lag, center, center + autocorrelation / 2 / radius, c="black")
plt.xlabel("Lag")
plt.ylabel("Autocorrelation")
plt.minorticks_on()
plt.axhline(0, linestyle="--", c="black", alpha=.75, lw=2)
make_square(plt.gca())
figure = plt.gcf()
return figure
示例14: find_golden_point_ex
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import axhline [as 别名]
def find_golden_point_ex(x, y, show=False):
"""统计黄金分割计算方法,以及对应简单可视化操作"""
sp382 = stats.scoreatpercentile(y, 38.2)
sp618 = stats.scoreatpercentile(y, 61.8)
sp50 = stats.scoreatpercentile(y, 50.0)
if show:
with plt_show():
# 可视化操作
plt.plot(x, y)
plt.axhline(sp50, color='c')
plt.axhline(sp618, color='r')
plt.axhline(sp382, color='g')
_ = plt.setp(plt.gca().get_xticklabels(), rotation=30)
plt.legend(['TLine', 'sp50', 'sp618', 'sp382'],
bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.)
return sp382, sp50, sp618
示例15: find_golden_point
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import axhline [as 别名]
def find_golden_point(x, y, show=False):
"""视觉黄金分割计算方法,以及对应简单可视化操作"""
cs_max = y.max()
cs_min = y.min()
sp382 = (cs_max - cs_min) * 0.382 + cs_min
sp618 = (cs_max - cs_min) * 0.618 + cs_min
sp50 = (cs_max - cs_min) * 0.5 + cs_min
if show:
with plt_show():
# 可视化操作
plt.plot(x, y)
plt.axhline(sp50, color='c')
plt.axhline(sp618, color='r')
plt.axhline(sp382, color='g')
_ = plt.setp(plt.gca().get_xticklabels(), rotation=30)
plt.legend(['TLine', 'sp50', 'sp618', 'sp382'],
bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.)
return sp382, sp50, sp618