当前位置: 首页>>代码示例>>Python>>正文


Python pyplot.MaxNLocator方法代码示例

本文整理汇总了Python中matplotlib.pyplot.MaxNLocator方法的典型用法代码示例。如果您正苦于以下问题:Python pyplot.MaxNLocator方法的具体用法?Python pyplot.MaxNLocator怎么用?Python pyplot.MaxNLocator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在matplotlib.pyplot的用法示例。


在下文中一共展示了pyplot.MaxNLocator方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: plot_overlap_matrix

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import MaxNLocator [as 别名]
def plot_overlap_matrix(overlap_matrix, color_map="bwr"):
    """
    Visualizes the pattern overlap

    Args:
        overlap_matrix:
        color_map:

    """

    plt.imshow(overlap_matrix, interpolation="nearest", cmap=color_map)
    plt.title("pattern overlap m(i,k)")
    plt.xlabel("pattern k")
    plt.ylabel("pattern i")
    plt.axes().get_xaxis().set_major_locator(plt.MaxNLocator(integer=True))
    plt.axes().get_yaxis().set_major_locator(plt.MaxNLocator(integer=True))
    cb = plt.colorbar(ticks=np.arange(-1, 1.01, 0.25).tolist())
    cb.set_clim(-1, 1)
    plt.show() 
开发者ID:EPFL-LCN,项目名称:neuronaldynamics-exercises,代码行数:21,代码来源:plot_tools.py

示例2: test_contourf_symmetric_locator

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import MaxNLocator [as 别名]
def test_contourf_symmetric_locator():
    # github issue 7271
    z = np.arange(12).reshape((3, 4))
    locator = plt.MaxNLocator(nbins=4, symmetric=True)
    cs = plt.contourf(z, locator=locator)
    assert_array_almost_equal(cs.levels, np.linspace(-12, 12, 5)) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:8,代码来源:test_contour.py

示例3: plot_state_sequence_and_overlap

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import MaxNLocator [as 别名]
def plot_state_sequence_and_overlap(state_sequence, pattern_list, reference_idx, color_map="brg", suptitle=None):
    """
    For each time point t ( = index of state_sequence), plots the sequence of states and the overlap (barplot)
    between state(t) and each pattern.

    Args:
        state_sequence: (list(numpy.ndarray))
        pattern_list: (list(numpy.ndarray))
        reference_idx: (int) identifies the pattern in pattern_list for which wrong pixels are colored.
    """
    if reference_idx is None:
        reference_idx = 0
    reference = pattern_list[reference_idx]
    f, ax = plt.subplots(2, len(state_sequence))
    if len(state_sequence) == 1:
        ax = [ax]
    _plot_list(ax[0, :], state_sequence, reference, "S{0}", color_map)
    for i in range(len(state_sequence)):
        overlap_list = pattern_tools.compute_overlap_list(state_sequence[i], pattern_list)
        ax[1, i].bar(range(len(overlap_list)), overlap_list)
        ax[1, i].set_title("m = {1}".format(i, round(overlap_list[reference_idx], 2)))
        ax[1, i].set_ylim([-1, 1])
        ax[1, i].get_xaxis().set_major_locator(plt.MaxNLocator(integer=True))
        if i > 0:  # show lables only for the first subplot
            ax[1, i].set_xticklabels([])
            ax[1, i].set_yticklabels([])
    if suptitle is not None:
        f.suptitle(suptitle)
    plt.show() 
开发者ID:EPFL-LCN,项目名称:neuronaldynamics-exercises,代码行数:31,代码来源:plot_tools.py

示例4: plot_prediction

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import MaxNLocator [as 别名]
def plot_prediction(ax, inputs, mean, std, area=2):
  order = np.argsort(inputs)
  inputs, mean, std = inputs[order], mean[order], std[order]
  ax.plot(inputs, mean, alpha=0.5)
  ax.fill_between(
      inputs, mean - area * std, mean + area * std, alpha=0.1, lw=0)
  ax.yaxis.set_major_locator(plt.MaxNLocator(5, prune='both'))
  ax.set_xlim(inputs.min(), inputs.max())
  min_, max_ = inputs.min(), inputs.max()
  min_ -= 0.1 * (max_ - min_ + 1e-6)
  max_ += 0.1 * (max_ - min_ + 1e-6)
  ax.set_xlim(min_, max_)
  ax.yaxis.tick_right()
  ax.yaxis.set_label_coords(-0.05, 0.5) 
开发者ID:brain-research,项目名称:ncp,代码行数:16,代码来源:plotting.py

示例5: plot_std_area

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import MaxNLocator [as 别名]
def plot_std_area(ax, inputs, std, **kwargs):
  kwargs['alpha'] = kwargs.get('alpha', 0.5)
  kwargs['lw'] = kwargs.get('lw', 0.0)
  order = np.argsort(inputs)
  inputs, std = inputs[order], std[order]
  ax.fill_between(inputs, std, 0 * std, **kwargs)
  ax.set_xlim(inputs.min(), inputs.max())
  ax.set_ylim(0, std.max())
  ax.yaxis.set_major_locator(plt.MaxNLocator(4, prune='both'))
  ax.yaxis.tick_right()
  ax.yaxis.set_label_coords(-0.05, 0.5) 
开发者ID:brain-research,项目名称:ncp,代码行数:13,代码来源:plotting.py

示例6: plot_results

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import MaxNLocator [as 别名]
def plot_results(args):
  load_results = lambda x: tools.load_results(
      os.path.join(args.logdir, x) + '-*/*.npz')
  results = [
      ('BBB+NCP', load_results('bbb_ncp')),
      ('ODC+NCP', load_results('det_mix_ncp')),
      ('BBB', load_results('bbb')),
      ('Det', load_results('det')),
  ]
  fig, ax = plt.subplots(ncols=4, figsize=(8, 2))
  for a in ax:
    a.xaxis.set_major_locator(plt.MaxNLocator(5))
    a.yaxis.set_major_locator(plt.MaxNLocator(5))
  tools.plot_distance(ax[0], results, 'train_distances', {})
  ax[0].set_xlabel('Data points seen')
  ax[0].set_title('Train RMSE')
  ax[0].set_ylim(0.1, 0.5)
  tools.plot_likelihood(ax[1], results, 'train_likelihoods', {})
  ax[1].set_xlabel('Data points seen')
  ax[1].set_title('Train NLPD')
  ax[1].set_ylim(-0.8, 0.7)
  tools.plot_distance(ax[2], results, 'test_distances', {})
  ax[2].set_xlabel('Data points seen')
  ax[2].set_title('Test RMSE')
  ax[2].set_ylim(0.35, 0.55)
  tools.plot_likelihood(ax[3], results, 'test_likelihoods', {})
  ax[3].set_xlabel('Data points seen')
  ax[3].set_title('Test NLPD')
  ax[3].set_ylim(0.4, 1.3)
  ax[3].legend(frameon=False, labelspacing=0.2, borderpad=0)
  fig.tight_layout(pad=0, w_pad=0.5)
  filename = os.path.join(args.logdir, 'results.pdf')
  fig.savefig(filename) 
开发者ID:brain-research,项目名称:ncp,代码行数:35,代码来源:toy_active.py

示例7: plot_figures

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import MaxNLocator [as 别名]
def plot_figures(self, prev_subplot_map=None):
        subplot_map = {}
        for idx, (environment, full_file_path) in enumerate(self.environments):
            environment = environment.split('level')[1].split('-')[1].split('Deterministic')[0][1:]
            if prev_subplot_map:
                # skip on environments which were not plotted before
                if environment not in prev_subplot_map.keys():
                    continue
                subplot_idx = prev_subplot_map[environment]
            else:
                subplot_idx = idx + 1
            print(environment)
            axis = plt.subplot(self.rows, self.cols, subplot_idx)
            subplot_map[environment] = subplot_idx
            signals = SignalsFile(full_file_path)
            signals.change_averaging_window(self.smoothness, force=True, signals=[self.signal_to_plot])
            steps = signals.bokeh_source.data[self.x_axis]
            rewards = signals.bokeh_source.data[self.signal_to_plot]

            yloc = plt.MaxNLocator(4)
            axis.yaxis.set_major_locator(yloc)
            axis.ticklabel_format(style='sci', axis='x', scilimits=(0, 0))
            plt.title(environment, fontsize=10, y=1.08)
            plt.plot(steps, rewards, self.color, linewidth=0.8)
            plt.subplots_adjust(hspace=2.0, wspace=0.4)

        return subplot_map 
开发者ID:NervanaSystems,项目名称:coach,代码行数:29,代码来源:plot_atari.py


注:本文中的matplotlib.pyplot.MaxNLocator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。