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


Python pyplot.NullLocator方法代码示例

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


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

示例1: hinton

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import NullLocator [as 别名]
def hinton(matrix, max_weight=None, ax=None):
    """Draw Hinton diagram for visualizing a weight matrix."""
    ax = ax if ax is not None else plt.gca()

    if not max_weight:
        max_weight = 2 ** np.ceil(np.log(np.abs(matrix).max()) / np.log(2))

    ax.patch.set_facecolor('gray')
    ax.set_aspect('equal', 'box')
    ax.xaxis.set_major_locator(plt.NullLocator())
    ax.yaxis.set_major_locator(plt.NullLocator())

    for (x, y), w in np.ndenumerate(matrix):
        color = 'white' if w > 0 else 'black'
        size = np.sqrt(np.abs(w) / max_weight)
        rect = plt.Rectangle([x - size / 2, y - size / 2], size, size,
                             facecolor=color, edgecolor=color)
        ax.add_patch(rect)

    ax.autoscale_view()
    ax.invert_yaxis() 
开发者ID:simonkamronn,项目名称:kvae,代码行数:23,代码来源:plotting.py

示例2: hinton

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import NullLocator [as 别名]
def hinton(matrix, max_weight=None, ax=None):
    """Draw Hinton diagram for visualizing a weight matrix."""
    ax = ax if ax is not None else plt.gca()

    if not max_weight:
        max_weight = 2 ** np.ceil(np.log(np.abs(matrix).max()) / np.log(2))

    ax.patch.set_facecolor('gray')
    ax.set_aspect('equal', 'box')
    ax.xaxis.set_major_locator(plt.NullLocator())
    ax.yaxis.set_major_locator(plt.NullLocator())

    for (x, y), w in np.ndenumerate(matrix):
        color = 'white' if w > 0 else 'black'
        size = np.sqrt(np.abs(w) / max_weight)
        rect = plt.Rectangle([x - size / 2, y - size / 2], size, size,
                             facecolor=color, edgecolor=color)
        ax.add_patch(rect)

    ax.autoscale_view()
    ax.invert_yaxis()

    return ax 
开发者ID:michtesar,项目名称:color_recognizer,代码行数:25,代码来源:hinton.py

示例3: Weights_opt

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import NullLocator [as 别名]
def Weights_opt(self, matrix, max_weight=None, ax=None):

        ax = ax if ax is not None else plt.gca()

        if not max_weight:
            max_weight = 2 ** np.ceil(np.log(np.abs(matrix).max()) / np.log(2))

        ax.patch.set_facecolor('gray')
        ax.set_aspect('equal', 'box')
        ax.xaxis.set_major_locator(plt.NullLocator())
        ax.yaxis.set_major_locator(plt.NullLocator())

        for (x, y), w in np.ndenumerate(matrix):
            color = 'white' if w > 0 else 'black'
            size = np.sqrt(np.abs(w))
            rect = plt.Rectangle([x - size / 2, y - size / 2], size, size,
                                 facecolor=color, edgecolor=color)
            ax.add_patch(rect)

        ax.autoscale_view()
        ax.invert_yaxis() 
开发者ID:thomaskuestner,项目名称:CNNArt,代码行数:23,代码来源:matplotlibwidget.py

示例4: view

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import NullLocator [as 别名]
def view(self):
        imgs = []
        for path in self.paths:
            img = plt.imread(path)
            imgs.append(img)

        fig, axs = plt.subplots(nrows=2, ncols=2, figsize=(12,16))
        fig.subplots_adjust(hspace=0.1, wspace=0)
        idx = 0
        for i in range(2):
            for j in range(2):
                axs[i,j].xaxis.set_major_locator(plt.NullLocator())
                axs[i,j].yaxis.set_major_locator(plt.NullLocator())
                axs[i,j].imshow(imgs[idx], cmap='bone')
                axs[i,j].set_xlabel(r'$(\alpha_'+str(idx+1) + ')$', fontsize=22)
                plt.tight_layout()
                idx = idx+1
        # save as a high quality image
        self.pdf.savefig(bbox_inches = 'tight', dpi=600)
        # plt.savefig(bbox_inches = 'tight', format='png', dpi=600)
        # plt.show() 
开发者ID:antoyang,项目名称:NAS-Benchmark,代码行数:23,代码来源:images_view.py

示例5: save

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import NullLocator [as 别名]
def save(path, remove_axis=False, dpi=300, fig=None):
  if fig is None:
    fig = plt.gcf()
  dirname = os.path.dirname(path)
  if dirname != '' and not os.path.exists(dirname):
    os.makedirs(dirname)
  if remove_axis:
    for ax in fig.axes:
      ax.axis('off')
      ax.margins(0,0)
    fig.subplots_adjust(top=1, bottom=0, right=1, left=0, hspace=0, wspace=0)
    for ax in fig.axes:
      ax.xaxis.set_major_locator(plt.NullLocator())
      ax.yaxis.set_major_locator(plt.NullLocator())
  fig.savefig(path, dpi=dpi, bbox_inches='tight', pad_inches=0) 
开发者ID:autonomousvision,项目名称:connecting_the_dots,代码行数:17,代码来源:plt.py

示例6: frame

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import NullLocator [as 别名]
def frame(I=None, second=5, saveable=True, name='frame', cmap=None, fig_idx=12836):
    """Display a frame(image). Make sure OpenAI Gym render() is disable before using it.

    Parameters
    ----------
    I : numpy.array
        The image
    second : int
        The display second(s) for the image(s), if saveable is False.
    saveable : boolean
        Save or plot the figure.
    name : a string
        A name to save the image, if saveable is True.
    cmap : None or string
        'gray' for greyscale, None for default, etc.
    fig_idx : int
        matplotlib figure index.

    Examples
    --------
    >>> env = gym.make("Pong-v0")
    >>> observation = env.reset()
    >>> tl.visualize.frame(observation)
    """
    if saveable is False:
        plt.ion()
    fig = plt.figure(fig_idx)      # show all feature images

    if len(I.shape) and I.shape[-1]==1:     # (10,10,1) --> (10,10)
        I = I[:,:,0]

    plt.imshow(I, cmap)
    plt.title(name)
    # plt.gca().xaxis.set_major_locator(plt.NullLocator())    # distable tick
    # plt.gca().yaxis.set_major_locator(plt.NullLocator())

    if saveable:
        plt.savefig(name+'.pdf',format='pdf')
    else:
        plt.draw()
        plt.pause(second) 
开发者ID:zjuela,项目名称:LapSRN-tensorflow,代码行数:43,代码来源:visualize.py

示例7: draw_label

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import NullLocator [as 别名]
def draw_label(label, img, label_names, colormap=None):
    plt.subplots_adjust(left=0, right=1, top=1, bottom=0,
                        wspace=0, hspace=0)
    plt.margins(0, 0)
    plt.gca().xaxis.set_major_locator(plt.NullLocator())
    plt.gca().yaxis.set_major_locator(plt.NullLocator())

    if colormap is None:
        colormap = label_colormap(len(label_names))

    label_viz = label2rgb(label, img, n_labels=len(label_names))
    plt.imshow(label_viz)
    plt.axis('off')

    plt_handlers = []
    plt_titles = []
    for label_value, label_name in enumerate(label_names):
        fc = colormap[label_value]
        p = plt.Rectangle((0, 0), 1, 1, fc=fc)
        plt_handlers.append(p)
        plt_titles.append(label_name)
    plt.legend(plt_handlers, plt_titles, loc='lower right', framealpha=.5)

    f = io.BytesIO()
    plt.savefig(f, bbox_inches='tight', pad_inches=0)
    plt.cla()
    plt.close()

    out_size = (img.shape[1], img.shape[0])
    out = PIL.Image.open(f).resize(out_size, PIL.Image.BILINEAR).convert('RGB')
    out = np.asarray(out)
    return out 
开发者ID:Jeff-sjtu,项目名称:labelKeypoint,代码行数:34,代码来源:utils.py

示例8: test_font_scaling

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import NullLocator [as 别名]
def test_font_scaling():
    matplotlib.rcParams['pdf.fonttype'] = 42
    fig, ax = plt.subplots(figsize=(6.4, 12.4))
    ax.xaxis.set_major_locator(plt.NullLocator())
    ax.yaxis.set_major_locator(plt.NullLocator())
    ax.set_ylim(-10, 600)

    for i, fs in enumerate(range(4, 43, 2)):
        ax.text(0.1, i*30, "{fs} pt font size".format(fs=fs), fontsize=fs) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:11,代码来源:test_text.py

示例9: hinton

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import NullLocator [as 别名]
def hinton(matrix, max_weight=None, ax=None, xtick=None, ytick=None, inverted_color=False):
    """Draw Hinton diagram for visualizing a weight matrix.

    Copied from: http://matplotlib.org/examples/specialty_plots/hinton_demo.html
    """
    ax = ax if ax is not None else plt.gca()
    if not max_weight:
        max_weight = 2**np.ceil(np.log(np.abs(matrix).max())/np.log(2))

    ax.patch.set_facecolor('gray')
    ax.set_aspect('equal', 'box')
    ax.xaxis.set_major_locator(plt.NullLocator())
    ax.yaxis.set_major_locator(plt.NullLocator())

    for (x, y), w in np.ndenumerate(matrix):
        if inverted_color:
            color = 'black' if w > 0 else 'white'
        else:
            color = 'white' if w > 0 else 'black'
        size = np.sqrt(np.abs(w))
        rect = plt.Rectangle([x - size / 2, y - size / 2], size, size,
                             facecolor=color, edgecolor=color)
        ax.add_patch(rect)

    ax.autoscale_view()
    ax.invert_yaxis()

    if xtick:
        ax.set_xticks(np.arange(matrix.shape[0]))
        ax.set_xticklabels(xtick)
    if ytick:
        ax.set_yticks(np.arange(matrix.shape[1]))
        ax.set_yticklabels(ytick)
    return ax 
开发者ID:kelvinguu,项目名称:lang2program,代码行数:36,代码来源:plot.py

示例10: atomicPlot

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import NullLocator [as 别名]
def atomicPlot(self, cmap='hot_r', vmin=None, vmax=None):
        """
        Just a handler to parametricPlot. Useful to plot energy levels.

        It adds a fake k-point. Shouldn't be invoked with more than one
        k-point
        """

        print("Atomic plot: bands.shape  :", self.bands.shape)
        print("Atomic plot: spd.shape    :", self.spd.shape)
        print("Atomic plot: kpoints.shape:", self.kpoints.shape)

        self.bands = np.hstack((self.bands, self.bands))
        self.spd = np.hstack((self.spd, self.spd))
        self.kpoints = np.vstack((self.kpoints, self.kpoints))
        self.kpoints[0][-1] += 1
        print("Atomic plot: bands.shape  :", self.bands.shape)
        print("Atomic plot: spd.shape    :", self.spd.shape)
        print("Atomic plot: kpoints.shape:", self.kpoints.shape)

        print(self.kpoints)

        fig = self.parametricPlot(cmap, vmin, vmax)
        plt.gca().xaxis.set_major_locator(plt.NullLocator())

        # labels on each band
        for i in range(len(self.bands[:, 0])):
            # print i, self.bands[i]
            plt.text(0, self.bands[i, 0], str(i + 1), fontsize=15)

        return fig 
开发者ID:MaterialsDiscovery,项目名称:PyChemia,代码行数:33,代码来源:procar.py

示例11: atomicPlot

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import NullLocator [as 别名]
def atomicPlot(self, cmap="hot_r", vmin=None, vmax=None, ax=None):
        """
    Just a handler to parametricPlot. Useful to plot energy levels.

    It adds a fake k-point. Shouldn't be invoked with more than one
    k-point
    ax not implemented here, not need
    """

        print("Atomic plot: bands.shape  :", self.bands.shape)
        print("Atomic plot: spd.shape    :", self.spd.shape)
        print("Atomic plot: kpoints.shape:", self.kpoints.shape)

        self.bands = np.hstack((self.bands, self.bands))
        self.spd = np.hstack((self.spd, self.spd))
        self.kpoints = np.vstack((self.kpoints, self.kpoints))
        self.kpoints[0][-1] += 1
        print("Atomic plot: bands.shape  :", self.bands.shape)
        print("Atomic plot: spd.shape    :", self.spd.shape)
        print("Atomic plot: kpoints.shape:", self.kpoints.shape)

        #        print(self.kpoints)

        fig, ax1 = self.parametricPlot(cmap, vmin, vmax, ax=ax)

        #        plt.gca().xaxis.set_major_locator(plt.NullLocator())
        ax1.xaxis.set_major_locator(plt.NullLocator())
        # labels on each band
        for i in range(len(self.bands[:, 0])):
            # print i, self.bands[i]
            ax1.text(0, self.bands[i, 0], str(i + 1))

        return fig, ax1 
开发者ID:romerogroup,项目名称:pyprocar,代码行数:35,代码来源:procarplot.py

示例12: detick

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import NullLocator [as 别名]
def detick(ax=None, x=True, y=True):
    """helper function for removing tick labels from an axis"""
    if not ax:
        ax = plt.gca()
    if x:
        ax.xaxis.set_major_locator(plt.NullLocator())
    if y:
        ax.yaxis.set_major_locator(plt.NullLocator()) 
开发者ID:ambrosejcarr,项目名称:seqc,代码行数:10,代码来源:plot.py

示例13: continuous

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import NullLocator [as 别名]
def continuous(x, y, c=None, ax=None, colorbar=True, randomize=True,
                   remove_ticks=False, **kwargs):
        """
        wrapper for scatter wherein the coordinates x and y are colored according to a
        continuous vector c
        :param x, y: np.ndarray, coordinate data
        :param c: np.ndarray, continuous vector by which to color data points
        :param remove_ticks: remove axis ticks and labels
        :param args: additional args for scatter
        :param kwargs: additional kwargs for scatter
        :return: ax
        """

        if ax is None:
            ax = plt.gca()

        if c is None:  # plot density if no color vector is provided
            x, y, c = scatter.density_2d(x, y)

        if randomize:
            ind = np.random.permutation(len(x))
        else:
            ind = np.argsort(c)

        sm = ax.scatter(x[ind], y[ind], c=c[ind], **kwargs)
        if remove_ticks:
            ax.xaxis.set_major_locator(plt.NullLocator())
            ax.yaxis.set_major_locator(plt.NullLocator())
        if colorbar:
            cb = plt.colorbar(sm)
            cb.ax.xaxis.set_major_locator(plt.NullLocator())
            cb.ax.yaxis.set_major_locator(plt.NullLocator())
        return ax 
开发者ID:ambrosejcarr,项目名称:seqc,代码行数:35,代码来源:plot.py

示例14: hinton

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import NullLocator [as 别名]
def hinton(matrix, max_weight=1.0, ax=None):
    """Draw Hinton diagram for visualizing a weight matrix."""
    ax = ax if ax is not None else plt.gca()

    if not max_weight:
        max_weight = 2 ** np.ceil(np.log(np.abs(matrix).max()) / np.log(2))

    ax.patch.set_facecolor('lightgrey')
    ax.set_aspect('equal', 'box')
    ax.xaxis.set_major_locator(plt.NullLocator())
    ax.yaxis.set_major_locator(plt.NullLocator())

    for (x, y), w in np.ndenumerate(matrix):
        color = np.arctan2(w.real, w.imag)
        color = ANGLE_MAPPER.to_rgba(color)
        size = np.sqrt(np.abs(w) / max_weight)
        rect = plt.Rectangle([x - size / 2, y - size / 2], size, size,
                             facecolor=color, edgecolor=color)
        ax.add_patch(rect)

    ax.set_xlim((-max_weight / 2, matrix.shape[0] - max_weight / 2))
    ax.set_ylim((-max_weight / 2, matrix.shape[1] - max_weight / 2))
    ax.autoscale_view()
    ax.invert_yaxis()


# From QuTiP which in turn modified the code from the SciPy Cookbook. 
开发者ID:rigetti,项目名称:forest-benchmarking,代码行数:29,代码来源:hinton.py

示例15: draw_density_estimation

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import NullLocator [as 别名]
def draw_density_estimation(self, axis, title, samples, cmap):
        axis.clear()
        axis.set_xlabel(title)
        density_estimation = numpy.zeros((self.l_kde, self.l_kde))
        for x, y in samples:
            if 0 < x < 1 and 0 < y < 1:
                density_estimation[int((1-y) / self.resolution)][int(x / self.resolution)] += 1
        density_estimation = filters.gaussian(density_estimation, self.bw_kde_)
        axis.imshow(density_estimation, cmap=cmap)
        axis.xaxis.set_major_locator(pyplot.NullLocator())
        axis.yaxis.set_major_locator(pyplot.NullLocator()) 
开发者ID:frombeijingwithlove,项目名称:dlcv_for_beginners,代码行数:13,代码来源:visualizer.py


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