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


Python image.AxesImage方法代码示例

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


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

示例1: _

# 需要导入模块: from matplotlib import image [as 别名]
# 或者: from matplotlib.image import AxesImage [as 别名]
def _(artist, event):
    if type(artist) != AxesImage:
        # Skip and warn on subclasses (`NonUniformImage`, `PcolorImage`) as
        # they do not implement `contains` correctly.  Even if they did, they
        # would not support moving as we do not know where a given index maps
        # back physically.
        return compute_pick.dispatch(object)(artist, event)
    contains, _ = artist.contains(event)
    if not contains:
        return
    ns = np.asarray(artist.get_array().shape[:2])[::-1]  # (y, x) -> (x, y)
    xy = np.array([event.xdata, event.ydata])
    xmin, xmax, ymin, ymax = artist.get_extent()
    # Handling of "upper" origin copied from AxesImage.get_cursor_data.
    if artist.origin == "upper":
        ymin, ymax = ymax, ymin
    low, high = np.array([[xmin, ymin], [xmax, ymax]])
    idxs = ((xy - low) / (high - low) * ns).astype(int)[::-1]
    target = _with_attrs(xy, index=tuple(idxs))
    return Selection(artist, target, 0, None, None) 
开发者ID:anntzer,项目名称:mplcursors,代码行数:22,代码来源:_pick_info.py

示例2: view

# 需要导入模块: from matplotlib import image [as 别名]
# 或者: from matplotlib.image import AxesImage [as 别名]
def view(self, figsize=(5, 5)) -> Tuple[Figure, AxesImage]:
        """View the current state of the board

        Parameters
        ----------
        figsize : tuple
            Size of the output figure

        Returns
        -------
        (:obj:`matplotlib.figure.Figure`, :obj:`matplotlib.image.AxesImage`)
            Graphical view of the board
        """
        fig = plt.figure(figsize=figsize)
        ax = fig.add_axes([0, 0, 1, 1], xticks=[], yticks=[], frameon=False)
        im = ax.imshow(self.state, cmap=plt.cm.binary, interpolation="nearest")
        im.set_clim(-0.05, 1)
        return fig, im 
开发者ID:ljvmiranda921,项目名称:seagull,代码行数:20,代码来源:board.py

示例3: view

# 需要导入模块: from matplotlib import image [as 别名]
# 或者: from matplotlib.image import AxesImage [as 别名]
def view(self, figsize=(5, 5)) -> Tuple[Figure, AxesImage]:
        """View the lifeform


        Returns
        -------
        matplotlib.axes._subplots.AxesSubplot
            Graphical view of the lifeform
        """
        fig = plt.figure(figsize=figsize)
        ax = fig.add_axes([0, 0, 1, 1], xticks=[], yticks=[], frameon=False)
        im = ax.imshow(
            self.layout, cmap=plt.cm.binary, interpolation="nearest"
        )
        im.set_clim(-0.05, 1)
        return fig, im 
开发者ID:ljvmiranda921,项目名称:seagull,代码行数:18,代码来源:base.py

示例4: __init__

# 需要导入模块: from matplotlib import image [as 别名]
# 或者: from matplotlib.image import AxesImage [as 别名]
def __init__(self, axes, model, interpolation="nearest", aspect="auto"):
        super(SliceView, self).__init__()
        data = np.zeros((1, 1))
        self._image = axes.imshow(data, interpolation=interpolation, aspect=aspect, origin='upper')
        """ :type: AxesImage """
        self._model = model
        """ :type: SliceModel """

        style = {"fill": False,
                 "alpha": 1,
                 "color": 'black',
                 "linestyle": 'dotted',
                 "linewidth": 0.75
                 }

        self._vertical_indicator = patches.Rectangle((-0.5, -0.5), 1, model.height, **style)
        self._horizontal_indicator = patches.Rectangle((-0.5, -0.5), model.width, 1, **style)
        self._zoom_factor = 1.0

        self._view_limits = None

        self._min_xlim = 0
        self._max_xlim = model.width
        self._min_ylim = 0
        self._max_ylim = model.height 
开发者ID:equinor,项目名称:segyviewer,代码行数:27,代码来源:sliceview.py

示例5: test_spatial_filter

# 需要导入模块: from matplotlib import image [as 别名]
# 或者: from matplotlib.image import AxesImage [as 别名]
def test_spatial_filter():
    """Test plotting a spatial filter directly."""
    # Plot filter
    _, spatial_filter, _ = utils.create_default_fake_filter()
    visualizations.spatial(spatial_filter)
    data = spatial_filter - spatial_filter.mean()

    # Verify data plotted correctly
    img = plt.findobj(plt.gca(), AxesImage)[0]
    assert np.all(img.get_array() == data), 'Spatial filter data is incorrect.'
    plt.close(plt.gcf())

    # Verify data plotted correctly when giving a maximum value
    maxval = np.abs(spatial_filter).max()
    visualizations.spatial(spatial_filter, maxval=maxval)
    img = plt.findobj(plt.gca(), AxesImage)[0]
    assert np.all(img.get_array() == spatial_filter), \
            'Spatial filter data incorrect when passing explicit maxval'
    assert np.all(img.get_clim() == np.array((-maxval, maxval))), \
            'Spatial filter color limits not set correctly.'
    plt.close(plt.gcf()) 
开发者ID:baccuslab,项目名称:pyret,代码行数:23,代码来源:test_visualizations.py

示例6: test_board_view

# 需要导入模块: from matplotlib import image [as 别名]
# 或者: from matplotlib.image import AxesImage [as 别名]
def test_board_view():
    """Test if a figure and image is returned whenever view is called"""
    board = Board(size=(3, 3))
    board.add(lf.Blinker(length=3), loc=(0, 1))
    fig, im = board.view()
    assert isinstance(fig, Figure)
    assert isinstance(im, AxesImage) 
开发者ID:ljvmiranda921,项目名称:seagull,代码行数:9,代码来源:test_board.py

示例7: test_lifeform_view

# 需要导入模块: from matplotlib import image [as 别名]
# 或者: from matplotlib.image import AxesImage [as 别名]
def test_lifeform_view(lifeform, cls):
    """Test if getting the lifeform view returns the expected tuple"""
    result = cls().view()
    assert len(result) == 2
    assert isinstance(result[0], Figure)
    assert isinstance(result[1], AxesImage) 
开发者ID:ljvmiranda921,项目名称:seagull,代码行数:8,代码来源:test_lifeforms.py

示例8: setCanvas

# 需要导入模块: from matplotlib import image [as 别名]
# 或者: from matplotlib.image import AxesImage [as 别名]
def setCanvas(self, **kwargs):
        """Set canvas to plot in

        :param figure: Matplotlib figure to plot in
        :type figure: :py:class:`matplotlib.Figure`
        :param axes: Matplotlib axes to plot in
        :type axes: :py:class:`matplotlib.Axes`
        :raises: TypeError
        """
        axes = kwargs.get('axes', None)
        figure = kwargs.get('figure', None)

        if isinstance(axes, plt.Axes):
            self.fig, self.ax = axes.get_figure(), axes
            self._show_plt = False
        elif isinstance(figure, plt.Figure):
            self.fig, self.ax = figure, figure.gca()
            self._show_plt = False
        elif axes is None and figure is None and self.fig is None:
            self.fig, self.ax = plt.subplots(1, 1)
            self._show_plt = True
        else:
            raise TypeError('axes has to be of type matplotlib.Axes. '
                            'figure has to be of type matplotlib.Figure')
        self.image = AxesImage(self.ax)
        self.ax.add_artist(self.image) 
开发者ID:pyrocko,项目名称:kite,代码行数:28,代码来源:plot2d.py

示例9: data

# 需要导入模块: from matplotlib import image [as 别名]
# 或者: from matplotlib.image import AxesImage [as 别名]
def data(self):
        """ Data passed to matplotlib.image.AxesImage """
        return self._data 
开发者ID:pyrocko,项目名称:kite,代码行数:5,代码来源:plot2d.py

示例10: plot

# 需要导入模块: from matplotlib import image [as 别名]
# 或者: from matplotlib.image import AxesImage [as 别名]
def plot(self, component='displacement', **kwargs):
        """Plots any component fom Scene
        The following components are recognizes

        - 'cartesian.dE'
        - 'cartesian.dN'
        - 'cartesian.dU'
        - 'displacement'
        - 'phi'
        - 'theta'

        :param **kwargs: Keyword args forwarded to `matplotlib.plt.imshow()`
        :type **kwargs: {dict}
        :param component: Component to plot
['cartesian.dE', 'cartesian.dN', 'cartesian.dU',
'displacement', 'phi', 'theta']
        :type component: {string}, optional
        :param axes: Axes instance to plot in, defaults to None
        :type axes: :py:class:`matplotlib.Axes`, optional
        :param figure: Figure instance to plot in, defaults to None
        :type figure: :py:class:`matplotlib.Figure`, optional
        :param **kwargs: kwargs are passed into `plt.imshow`
        :type **kwargs: dict
        :returns: Imshow instance
        :rtype: :py:class:`matplotlib.image.AxesImage`
        :raises: AttributeError
        """
        self._initImagePlot(**kwargs)
        self.component = component
        self.title = self.components_available[component]

        if self._show_plt:
            plt.show() 
开发者ID:pyrocko,项目名称:kite,代码行数:35,代码来源:plot2d.py

示例11: onpick4

# 需要导入模块: from matplotlib import image [as 别名]
# 或者: from matplotlib.image import AxesImage [as 别名]
def onpick4(event):
        artist = event.artist
        if isinstance(artist, AxesImage):
            im = artist
            A = im.get_array()
            print('onpick4 image', A.shape) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:8,代码来源:pick_event_demo.py

示例12: set_transparency

# 需要导入模块: from matplotlib import image [as 别名]
# 或者: from matplotlib.image import AxesImage [as 别名]
def set_transparency(self, value):

        if self.mode > 3:
            self.trans = value
            if bool(self.flipimage % 4):
                self.view_flip_image()
            else:
                self.view_image()
        else:
            for item in self.ax1.get_children():
                if not type(item) == AxesImage:
                    self.artist_list.append(item)
            for artist in self.artist_list:
                artist.set_alpha(value)
                self.figure.canvas.draw() 
开发者ID:thomaskuestner,项目名称:CNNArt,代码行数:17,代码来源:canvas.py

示例13: plot_weights

# 需要导入模块: from matplotlib import image [as 别名]
# 或者: from matplotlib.image import AxesImage [as 别名]
def plot_weights(
    weights: torch.Tensor,
    wmin: Optional[float] = 0,
    wmax: Optional[float] = 1,
    im: Optional[AxesImage] = None,
    figsize: Tuple[int, int] = (5, 5),
    cmap: str = "hot_r",
) -> AxesImage:
    # language=rst
    """
    Plot a connection weight matrix.

    :param weights: Weight matrix of ``Connection`` object.
    :param wmin: Minimum allowed weight value.
    :param wmax: Maximum allowed weight value.
    :param im: Used for re-drawing the weights plot.
    :param figsize: Horizontal, vertical figure size in inches.
    :param cmap: Matplotlib colormap.
    :return: ``AxesImage`` for re-drawing the weights plot.
    """
    local_weights = weights.detach().clone().cpu().numpy()
    if not im:
        fig, ax = plt.subplots(figsize=figsize)

        im = ax.imshow(local_weights, cmap=cmap, vmin=wmin, vmax=wmax)
        div = make_axes_locatable(ax)
        cax = div.append_axes("right", size="5%", pad=0.05)

        ax.set_xticks(())
        ax.set_yticks(())
        ax.set_aspect("auto")

        plt.colorbar(im, cax=cax)
        fig.tight_layout()
    else:
        im.set_data(local_weights)

    return im 
开发者ID:BINDS-LAB-UMASS,项目名称:bindsnet,代码行数:40,代码来源:plotting.py

示例14: test_play_sta

# 需要导入模块: from matplotlib import image [as 别名]
# 或者: from matplotlib.image import AxesImage [as 别名]
def test_play_sta():
    """Test playing an STA as a movie by comparing a known frame."""
    sta = utils.create_default_fake_filter()[-1]
    sta -= sta.mean()
    frame = utils.get_default_movie_frame()
    animation = visualizations.play_sta(sta)
    animation._func(frame)
    imgdata = plt.findobj(plt.gcf(), AxesImage)[0].get_array()
    imgdata -= imgdata.mean()
    data = sta[frame, ...]
    data -= data.mean()
    assert np.allclose(imgdata, data), \
            'visualizations.play_sta did not animate the 3D sta correctly.' 
开发者ID:baccuslab,项目名称:pyret,代码行数:15,代码来源:test_visualizations.py

示例15: plot_input

# 需要导入模块: from matplotlib import image [as 别名]
# 或者: from matplotlib.image import AxesImage [as 别名]
def plot_input(
    image: torch.Tensor,
    inpt: torch.Tensor,
    label: Optional[int] = None,
    axes: List[Axes] = None,
    ims: List[AxesImage] = None,
    figsize: Tuple[int, int] = (8, 4),
) -> Tuple[List[Axes], List[AxesImage]]:
    # language=rst
    """
    Plots a two-dimensional image and its corresponding spike-train representation.

    :param image: A 2D array of floats depicting an input image.
    :param inpt: A 2D array of floats depicting an image's spike-train encoding.
    :param label: Class label of the input data.
    :param axes: Used for re-drawing the input plots.
    :param ims: Used for re-drawing the input plots.
    :param figsize: Horizontal, vertical figure size in inches.
    :return: Tuple of ``(axes, ims)`` used for re-drawing the input plots.
    """
    local_image = image.detach().clone().cpu().numpy()
    local_inpy = inpt.detach().clone().cpu().numpy()

    if axes is None:
        fig, axes = plt.subplots(1, 2, figsize=figsize)
        ims = (
            axes[0].imshow(local_image, cmap="binary"),
            axes[1].imshow(local_inpy, cmap="binary"),
        )

        if label is None:
            axes[0].set_title("Current image")
        else:
            axes[0].set_title("Current image (label = %d)" % label)

        axes[1].set_title("Reconstruction")

        for ax in axes:
            ax.set_xticks(())
            ax.set_yticks(())

        fig.tight_layout()
    else:
        if label is not None:
            axes[0].set_title("Current image (label = %d)" % label)

        ims[0].set_data(local_image)
        ims[1].set_data(local_inpy)

    return axes, ims 
开发者ID:BindsNET,项目名称:bindsnet,代码行数:52,代码来源:plotting.py


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