Python matplotlib.pyplot.axhline() Examples
The following are 30
code examples of matplotlib.pyplot.axhline().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
matplotlib.pyplot
, or try the search function
.
Example #1
Source File: analyse_orderless_NADE.py From NADE with BSD 3-Clause "New" or "Revised" License | 6 votes |
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"))
Example #2
Source File: ABuTLExecute.py From abu with GNU General Public License v3.0 | 6 votes |
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
Example #3
Source File: mcmc.py From hypothesis with BSD 3-Clause "New" or "Revised" License | 6 votes |
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
Example #4
Source File: ABuTLExecute.py From abu with GNU General Public License v3.0 | 6 votes |
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
Example #5
Source File: ABuTLJump.py From abu with GNU General Public License v3.0 | 6 votes |
def _show_jump_line(kl_pd, jump_lines): """ 可视化AbuJumpTuple对象序列jump_lines中所有的跳空点 :param kl_pd: 金融时间序列,pd.DataFrame对象 :param jump_lines: AbuJumpTuple对象序列 """ with plt_show(): plt.plot(kl_pd.close) # 迭代跳空点,通过itertools.cycle(K_PLT_MAP_STYLE)形成不同的颜色 for jump_tuple, cs_color in zip(jump_lines, itertools.cycle(K_PLT_MAP_STYLE)): # 跳空点位对应的价格上面绘制横线,label标注跳空能量 plt.axhline(jump_tuple.price, color=cs_color, label='power:' + str(jump_tuple.power)) # 跳空描述:日期:up/down, 根据jump_tuple.direction跳空方向 jump_desc = '{} : {}'.format(jump_tuple.date, ' up ' if jump_tuple.direction > 0 else ' down ') # 再把这个跳空时间点上画一个圆圈进行标示 plt.plot(jump_tuple.date, jump_tuple.price, 'ro', markersize=12, markeredgewidth=(1.0 * jump_tuple.power), markerfacecolor='None', markeredgecolor=cs_color, label=jump_desc) plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.) plt.title('jump lines')
Example #6
Source File: m_dos_pdos_eigenvalues.py From pyscf with Apache License 2.0 | 6 votes |
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()
Example #7
Source File: __init__.py From DynaPhoPy with MIT License | 6 votes |
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()
Example #8
Source File: solaryears.py From flatlib with MIT License | 6 votes |
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
Example #9
Source File: SpeechRecorder.py From adviser with GNU General Public License v3.0 | 6 votes |
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
Example #10
Source File: leapyears.py From flatlib with MIT License | 6 votes |
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
Example #11
Source File: avg_network.py From MD-TASK with GNU General Public License v3.0 | 6 votes |
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)
Example #12
Source File: plot.py From pwptemp with GNU Lesser General Public License v3.0 | 6 votes |
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()
Example #13
Source File: plot.py From pwptemp with GNU Lesser General Public License v3.0 | 6 votes |
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()
Example #14
Source File: plot.py From pwptemp with GNU Lesser General Public License v3.0 | 6 votes |
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()
Example #15
Source File: hicCompartmentalization.py From HiCExplorer with GNU General Public License v3.0 | 6 votes |
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)
Example #16
Source File: ABuTLine.py From abu with GNU General Public License v3.0 | 5 votes |
def show(self): """可视化技术线最基本的信息,high,mean,low""" plt.subplots(figsize=ABuEnv.g_plt_figsize) # tl装载技术线本体 plt.plot(self.tl) plt.axhline(self.high, color='c') plt.axhline(self.mean, color='r') plt.axhline(self.low, color='g') _ = plt.setp(plt.gca().get_xticklabels(), rotation=30) plt.legend(['TLine', 'high', 'mean', 'low'], bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.) plt.title(self.line_name) plt.show()
Example #17
Source File: plotting.py From auptimizer with GNU General Public License v3.0 | 5 votes |
def main_plot_history(trials, bandit=None, algo=None, do_show=True, status_colors=None): # -- import here because file-level import is too early import matplotlib.pyplot as plt # self is an Experiment if status_colors is None: status_colors = default_status_colors # XXX: show the un-finished or error trials Ys, colors = zip(*[(y, status_colors[s]) for y, s in zip(trials.losses(bandit), trials.statuses(bandit)) if y is not None]) plt.scatter(range(len(Ys)), Ys, c=colors) plt.xlabel('time') plt.ylabel('loss') if bandit is not None and bandit.loss_target is not None: plt.axhline(bandit.loss_target) ymin = min(np.min(Ys), bandit.loss_target) ymax = max(np.max(Ys), bandit.loss_target) yrange = ymax - ymin ymean = (ymax + ymin) / 2.0 plt.ylim( ymean - 0.53 * yrange, ymean + 0.53 * yrange, ) best_err = trials.average_best_error(bandit) print("avg best error:", best_err) plt.axhline(best_err, c='g') plt.title('bandit: %s algo: %s' % ( bandit.short_str() if bandit else '-', algo_as_str(algo))) if do_show: plt.show()
Example #18
Source File: plotting.py From auptimizer with GNU General Public License v3.0 | 5 votes |
def main_show(self, title=None): self.add_scatters() if title: plt.title(title) # plt.axvline(25) # make a parameter # plt.axhline(.2) # plt.axhline(.3) plt.show()
Example #19
Source File: plotting.py From auptimizer with GNU General Public License v3.0 | 5 votes |
def main_plot_histories(cls): import plotting conn_str_template = sys.argv[2] algos = sys.argv[3].split(',') dataset_name = sys.argv[4] start = int(sys.argv[5]) if len(sys.argv) > 5 else 0 stop = int(sys.argv[6]) if len(sys.argv) > 6 else sys.maxint mh = plotting.MultiHistory() colors = ['r', 'y', 'b', 'g', 'c', 'k'] def custom_err_fn(trial): if 2 == trial['status']: rval = 1.0 - trial['result']['best_epoch_valid'] if rval > dict( convex=.4, mnist_rotated_background_images=2)[dataset_name]: return None else: return rval for c, algo in zip(colors, algos): conn_str = conn_str_template % (algo, dataset_name) print('algo', algo) mh.add_experiment( mj=MongoJobs.new_from_connection_str(conn_str), y_fn=custom_err_fn, color=c, label=algo, start=start, stop=stop) plt = plotting.plt # TODO: icml07 undefined plt.axhline( 1.0 - icml07.dbn3_scores[dataset_name], c='k', label='manual+grid') # , dashes=[0,1]) mh.add_scatters() plt.legend() plt.title(dataset_name) plt.show()
Example #20
Source File: __init__.py From DynaPhoPy with MIT License | 5 votes |
def plot_frequencies_vs_linewidths(self): qpoints, multiplicity, frequencies, linewidths = self.get_mesh_frequencies_and_linewidths() plt.ylabel('Linewidth [THz]') plt.xlabel('Frequency [THz]') plt.axhline(y=0, color='k', ls='dashed') plt.title('Frequency vs linewidths (from mesh: {})'.format(self.parameters.mesh_phonopy)) plt.scatter(np.array(frequencies).flatten(), np.array(linewidths).flatten(), s=multiplicity) plt.show()
Example #21
Source File: chart.py From XQuant with MIT License | 5 votes |
def _plot_tracks(tracks): colors = ['r', 'b'] n_tracks = min({len(tracks.columns), len(colors)}) for i in range(n_tracks): ob = tracks.iloc[:, i].values plt.plot(tracks.index, ob, colors[i], lw=0.5) plt.ylim(((1.1 if min(ob) < 0 else -1.1) * min(ob), 1.1 * max(ob))) if min(ob) < 0 < max(ob): plt.axhline(y=0.0, color='k', lw=0.5)
Example #22
Source File: evaluation.py From ngboost with Apache License 2.0 | 5 votes |
def plot_pit_histogram(predicted, observed, **kwargs): plt.bar( x=predicted[1:], height=np.diff(observed), width=-np.diff(predicted), align="edge", fill=False, edgecolor="black", **kwargs ) plt.xlim((0, 1)) plt.xlabel("Probability Integral Transform") plt.ylabel("Density") plt.axhline(1.0 / (len(predicted) - 1), linestyle="--", color="grey") plt.title("PIT Histogram")
Example #23
Source File: generate_loss_plots.py From Variational_Discriminator_Bottleneck with MIT License | 5 votes |
def plot_loss(*loss_vals, plot_name="Loss plot", fig_size=(17, 7), save_path=None, legends=("discriminator", "bottleneck", "generator")): """ plot the discriminator loss values and save the plot if required :param loss_vals: (Variable Arg) numpy array or Sequence like for plotting values :param plot_name: Name of the plot :param fig_size: size of the generated figure (column_width, row_width) :param save_path: path to save the figure :param legends: list containing labels for loss plots' legends len(legends) == len(loss_vals) :return: """ assert len(loss_vals) == len(legends), "Not enough labels for legends" plt.figure(figsize=fig_size).suptitle(plot_name) plt.grid(True, which="both") plt.ylabel("loss value") plt.xlabel("spaced iterations") plt.axhline(y=0, color='k') plt.axvline(x=0, color='k') # plot all the provided loss values in a single plot plts = [] for loss_val in loss_vals: plts.append(plt.plot(loss_val)[0]) plt.legend(plts, legends, loc="upper right", fontsize=16) if save_path is not None: plt.savefig(save_path)
Example #24
Source File: tools.py From DMDpack with GNU General Public License v3.0 | 5 votes |
def plot_modes( omega, color='r', color2='blue', name=None, maker='o', alpha = 0.3, labelon=True, xytx=-20, xyty=20): m = len(omega) labels = ['mode{0}'.format(i) for i in range(m)] plt.subplots_adjust(bottom = 0.1) #vert line plt.axvline(x=0,color='k',ls='dashed', lw=2) #horiz line plt.axhline(y=0,color='k',ls='dashed', lw=2) #plot omega plt.scatter( omega.real, omega.imag, marker = maker, c = color, s=20*9, label = name ) #plot labels if labelon==True: for label, x, y in zip(labels, omega.real, omega.imag): xytx2, xyty2 = xytx, xyty color2=np.array([0.4, 0.4, 1.]) plt.annotate( label, xy = (x, y), xytext = (xytx2, xyty2), textcoords = 'offset points', ha = 'right', va = 'bottom', fontsize=12, color='white', bbox = dict(boxstyle = 'round,pad=0.5', fc = color2, alpha = alpha), arrowprops = dict(facecolor='black', shrink=0.11)) plt.grid(True) plt.tight_layout() plt.xlabel('Real', fontsize=25) plt.ylabel('Imaginary', fontsize=25) plt.tick_params(axis='y', labelsize=18) plt.tick_params(axis='x', labelsize=18) #if name != None: plt.legend(loc="lower right", fontsize=25) plt.show()
Example #25
Source File: generate_loss_plots.py From pro_gan_pytorch-examples with MIT License | 5 votes |
def plot_loss(*loss_vals, plot_name="Loss plot", fig_size=(17, 7), save_path=None, legends=("discriminator", "generator")): """ plot the discriminator loss values and save the plot if required :param loss_vals: (Variable Arg) numpy array or Sequence like for plotting values :param plot_name: Name of the plot :param fig_size: size of the generated figure (column_width, row_width) :param save_path: path to save the figure :param legends: list containing labels for loss plots' legends len(legends) == len(loss_vals) :return: """ assert len(loss_vals) == len(legends), "Not enough labels for legends" plt.figure(figsize=fig_size).suptitle(plot_name) plt.grid(True, which="both") plt.ylabel("loss value") plt.xlabel("spaced iterations") plt.axhline(y=0, color='k') plt.axvline(x=0, color='k') # plot all the provided loss values in a single plot plts = [] for loss_val in loss_vals: plts.append(plt.plot(loss_val)[0]) plt.legend(plts, legends, loc="upper right", fontsize=16) if save_path is not None: plt.savefig(save_path)
Example #26
Source File: generate_loss_plots.py From fagan with MIT License | 5 votes |
def plot_loss(*loss_vals, plot_name="Loss plot", fig_size=(17, 7), save_path=None, legends=("discriminator", "generator")): """ plot the discriminator loss values and save the plot if required :param loss_vals: (Variable Arg) numpy array or Sequence like for plotting values :param plot_name: Name of the plot :param fig_size: size of the generated figure (column_width, row_width) :param save_path: path to save the figure :param legends: list containing labels for loss plots' legends len(legends) == len(loss_vals) :return: """ assert len(loss_vals) == len(legends), "Not enough labels for legends" plt.figure(figsize=fig_size).suptitle(plot_name) plt.grid(True, which="both") plt.ylabel("loss value") plt.xlabel("spaced iterations") plt.axhline(y=0, color='k') plt.axvline(x=0, color='k') # plot all the provided loss values in a single plot plts = [] for loss_val in loss_vals: plts.append(plt.plot(loss_val)[0]) plt.legend(plts, legends, loc="upper right", fontsize=16) if save_path is not None: plt.savefig(save_path)
Example #27
Source File: ablation_plot.py From time-attention with MIT License | 5 votes |
def barchart(data, i, types, label): bars = len(types) - 1 plt.bar( range(bars), [d[i] for d in data][:-1], 0.35, color=list(mcolors.TABLEAU_COLORS)[: bars], ) plt.axhline(y=data[-1][i], zorder=3, color="red", label='da-rnn') plt.xticks(range(bars), types[:-1]) plt.ylabel(label) plt.legend() plt.title("Attention comparison (the lower the better)") plt.show()
Example #28
Source File: pval.py From mictools with GNU General Public License v3.0 | 5 votes |
def plot_pi0(pi0, pi0_lmb, lmb, pi0_smooth, output_fn): fig = plt.figure(figsize=(6, 6)) ax1 = plt.subplot(111) plt.plot(lmb, pi0_lmb, 'ko') if not pi0_smooth is None: plt.plot(lmb, pi0_smooth, 'k', label='Quadratic smoothing') plt.axhline(pi0, linestyle='--', color='r', label='pi0') plt.xlabel("lambda") plt.ylabel("pi0(lambda)") plt.legend() fig.savefig(output_fn, bbox_inches='tight', dpi=300, format='png')
Example #29
Source File: c3.py From abu with GNU General Public License v3.0 | 5 votes |
def sample_322(): """ 3.2.2 统计基础概念 :return: """ a_investor = np.random.normal(loc=100, scale=50, size=(100, 1)) b_investor = np.random.normal(loc=100, scale=20, size=(100, 1)) # a交易者 print('a交易者期望{0:.2f}元, 标准差{1:.2f}, 方差{2:.2f}'.format( a_investor.mean(), a_investor.std(), a_investor.var())) # b交易者 print('b交易者期望{0:.2f}元, 标准差{1:.2f}, 方差{2:.2f}'.format( b_investor.mean(), b_investor.std(), b_investor.var())) # a交易者期望 a_mean = a_investor.mean() # a交易者标注差 a_std = a_investor.std() # 收益绘制曲线 plt.plot(a_investor) # 水平直线 上线 plt.axhline(a_mean + a_std, color='r') # 水平直线 均值期望线 plt.axhline(a_mean, color='y') # 水平直线 下线 plt.axhline(a_mean - a_std, color='g') plt.show() b_mean = b_investor.mean() b_std = b_investor.std() # b交易者收益绘制曲线 plt.plot(b_investor) # 水平直线 上线 plt.axhline(b_mean + b_std, color='r') # 水平直线 均值期望线 plt.axhline(b_mean, color='y') # 水平直线 下线 plt.axhline(b_mean - b_std, color='g') plt.show()
Example #30
Source File: calc_delta.py From MD-TASK with GNU General Public License v3.0 | 5 votes |
def calc_delta(reference_file, alternative_files, normalizer, generate_plots=False): reference = np.loadtxt(reference_file) num_nodes = reference.shape[0] label = normalizer.get_label() alternatives = natsorted(alternative_files) log.info("Calculating %s for %d networks...\n" % (label, len(alternatives))) for i, alternative in enumerate(alternatives): log.info("Calculating %s (%d/%d)\r" % (label, i + 1, len(alternatives))) title = ".".join(alternative.split(".")[:-1]) alternative = np.loadtxt(alternative) difference = alternative - reference difference = normalizer.normalize(difference, reference) prefix = "%s_%s_delta_%s" % (title, normalizer.get_prefix(), normalizer.matrix_type) np.savetxt("%s.dat" % prefix, difference) if generate_plots: node_axis = range(1, num_nodes + 1) plt.plot(node_axis, difference) plt.axhline(0, color='black') plt.title("%s %s" % (title, label), fontsize=18) plt.xlabel('Residue Numbers', fontsize=16) plt.ylabel(label, fontsize=16) plt.savefig("%s.png" % prefix, dpi=300, bbox_inches="tight") plt.close() log.info("\n")