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


Python collections.EllipseCollection方法代码示例

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


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

示例1: test_EllipseCollection

# 需要导入模块: from matplotlib import collections [as 别名]
# 或者: from matplotlib.collections import EllipseCollection [as 别名]
def test_EllipseCollection():
    # Test basic functionality
    fig, ax = plt.subplots()
    x = np.arange(4)
    y = np.arange(3)
    X, Y = np.meshgrid(x, y)
    XY = np.vstack((X.ravel(), Y.ravel())).T

    ww = X/float(x[-1])
    hh = Y/float(y[-1])
    aa = np.ones_like(ww) * 20  # first axis is 20 degrees CCW from x axis

    ec = mcollections.EllipseCollection(ww, hh, aa,
                                        units='x',
                                        offsets=XY,
                                        transOffset=ax.transData,
                                        facecolors='none')
    ax.add_collection(ec)
    ax.autoscale_view() 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:21,代码来源:test_collections.py

示例2: test_EllipseCollection

# 需要导入模块: from matplotlib import collections [as 别名]
# 或者: from matplotlib.collections import EllipseCollection [as 别名]
def test_EllipseCollection():
    # Test basic functionality
    fig, ax = plt.subplots()
    x = np.arange(4)
    y = np.arange(3)
    X, Y = np.meshgrid(x, y)
    XY = np.vstack((X.ravel(), Y.ravel())).T

    ww = X / x[-1]
    hh = Y / y[-1]
    aa = np.ones_like(ww) * 20  # first axis is 20 degrees CCW from x axis

    ec = mcollections.EllipseCollection(ww, hh, aa,
                                        units='x',
                                        offsets=XY,
                                        transOffset=ax.transData,
                                        facecolors='none')
    ax.add_collection(ec)
    ax.autoscale_view() 
开发者ID:holzschu,项目名称:python3_ios,代码行数:21,代码来源:test_collections.py

示例3: test_size_in_xy

# 需要导入模块: from matplotlib import collections [as 别名]
# 或者: from matplotlib.collections import EllipseCollection [as 别名]
def test_size_in_xy():
    fig, ax = plt.subplots()

    widths, heights, angles = (10, 10), 10, 0
    widths = 10, 10
    coords = [(10, 10), (15, 15)]
    e = mcollections.EllipseCollection(
        widths, heights, angles,
        units='xy',
        offsets=coords,
        transOffset=ax.transData)

    ax.add_collection(e)

    ax.set_xlim(0, 30)
    ax.set_ylim(0, 30) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:18,代码来源:test_collections.py

示例4: overlay_fibers

# 需要导入模块: from matplotlib import collections [as 别名]
# 或者: from matplotlib.collections import EllipseCollection [as 别名]
def overlay_fibers(self, ax, diameter=None, skies=None, return_figure=True, **kwargs):
        """ Overlay the individual fibers within an IFU on a plot.

        Parameters:
            ax (Axis):
                The matplotlib axis object
            diameter (float):
                The fiber diameter in arcsec. Default is 2".
            skies (bool):
                Set to True to additionally overlay the sky fibers. Default if False
            return_figure (bool):
                If True, returns the figure axis object.  Default is True
            kwargs:
                Any keyword arguments accepted by Matplotlib EllipseCollection
        """

        if self.wcs is None:
            raise MarvinError('No WCS found.  Cannot overlay fibers.')

        # check the diameter
        if diameter:
            assert isinstance(diameter, (float, int)), 'diameter must be a number'
        diameter = (diameter or 2.0) / float(self.header['SCALE'])

        # get the fiber pixel coordinates
        fibers = self.bundle.fibers[:, [1, 2]]
        fiber_pix = self.wcs.wcs_world2pix(fibers, 1)

        # some matplotlib kwargs
        kwargs['edgecolor'] = kwargs.get('edgecolor', 'Orange')
        kwargs['facecolor'] = kwargs.get('facecolor', 'none')
        kwargs['linewidth'] = kwargs.get('linewidth', 0.4)

        ec = EllipseCollection(diameter, diameter, 0.0, units='xy',
                               offsets=fiber_pix, transOffset=ax.transData,
                               **kwargs)
        ax.add_collection(ec)

        # overlay the sky fibers
        if skies:
            self.overlay_skies(ax, diameter=diameter, return_figure=return_figure, **kwargs)

        if return_figure:
            return ax 
开发者ID:sdss,项目名称:marvin,代码行数:46,代码来源:image.py

示例5: overlay_skies

# 需要导入模块: from matplotlib import collections [as 别名]
# 或者: from matplotlib.collections import EllipseCollection [as 别名]
def overlay_skies(self, ax, diameter=None, return_figure=True, **kwargs):
        """ Overlay the sky fibers on a plot

        Parameters:
            ax (Axis):
                The matplotlib axis object
            diameter (float):
                The fiber diameter in arcsec
            return_figure (bool):
                If True, returns the figure axis object.  Default is True
            kwargs:
                Any keyword arguments accepted by Matplotlib EllipseCollection
        """

        if self.wcs is None:
            raise MarvinError('No WCS found.  Cannot overlay sky fibers.')

        # check for sky coordinates
        if self.bundle.skies is None:
            self.bundle.get_sky_coordinates()

        # check the diameter
        if diameter:
            assert isinstance(diameter, (float, int)), 'diameter must be a number'
        diameter = (diameter or 2.0) / float(self.header['SCALE'])

        # get sky fiber pixel positions
        fiber_pix = self.wcs.wcs_world2pix(self.bundle.skies, 1)
        outside_range = ((fiber_pix < 0) | (fiber_pix > self.data.size[0])).any()
        if outside_range:
            raise MarvinError('Cannot overlay sky fibers.  Image is too small.  '
                              'Please retrieve a bigger image cutout')

        # some matplotlib kwargs
        kwargs['edgecolor'] = kwargs.get('edgecolor', 'Orange')
        kwargs['facecolor'] = kwargs.get('facecolor', 'none')
        kwargs['linewidth'] = kwargs.get('linewidth', 0.7)

        # draw the sky fibers
        ec = EllipseCollection(diameter, diameter, 0.0, units='xy',
                               offsets=fiber_pix, transOffset=ax.transData,
                               **kwargs)
        ax.add_collection(ec)

        # Add a larger circle to help identify the sky fiber locations in large images.
        if (self.data.size[0] > 1000) or (self.data.size[1] > 1000):
            ec = EllipseCollection(diameter * 5, diameter * 5, 0.0, units='xy',
                                   offsets=fiber_pix, transOffset=ax.transData,
                                   **kwargs)
            ax.add_collection(ec)

        if return_figure:
            return ax 
开发者ID:sdss,项目名称:marvin,代码行数:55,代码来源:image.py


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