當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。