本文整理匯總了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()
示例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()
示例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)
示例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
示例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