23"""lsst.afw.geom.ellipses
25from ._ellipses
import *
26from ._ellipse
import *
28from ._quadrupole
import *
31 (Distortion, DeterminantRadius): SeparableDistortionDeterminantRadius,
32 (Distortion, TraceRadius): SeparableDistortionTraceRadius,
33 (Distortion, LogDeterminantRadius): SeparableDistortionLogDeterminantRadius,
34 (Distortion, LogTraceRadius): SeparableDistortionLogTraceRadius,
35 (ConformalShear, DeterminantRadius): SeparableConformalShearDeterminantRadius,
36 (ConformalShear, TraceRadius): SeparableConformalShearTraceRadius,
37 (ConformalShear, LogDeterminantRadius): SeparableConformalShearLogDeterminantRadius,
38 (ConformalShear, LogTraceRadius): SeparableConformalShearLogTraceRadius
43 """An interface for drawing the ellipse using matplotlib.
45 This is typically initiated by calling Ellipse.plot(), which
46 returns an instance of this class.
49 def __init__(self, ellipse, scale=1.0, **kwds):
50 import matplotlib.patches
56 core.scale(2.0 * scale)
57 self.
patch = matplotlib.patches.Ellipse(
59 core.getA(), core.getB(), core.getTheta() * 180.0 / np.pi,
64 return getattr(self.
patch, name)
66 def update(self, show=True, rescale=True):
67 """Update the matplotlib representation to the current ellipse parameters.
69 import matplotlib.patches
71 core = _agl.Axes(self.
__ellipse.getCore())
72 core.scale(2.0 * scale)
73 new_patch = matplotlib.patches.Ellipse(
75 core.a, core.b, core.theta * 180.0 / np.pi
77 new_patch.update_from(self.
patch)
78 axes = self.
patch.get_axes()
81 axes.add_patch(new_patch)
82 self.
patch = new_patch
87 axes.figure.canvas.draw()
90def Ellipse_plot(self, axes=None, scale=1.0, show=True, rescale=True, **kwds):
91 """Plot the ellipse in matplotlib, adding a MatplotlibInterface
92 object as the 'matplotlib' attribute of the ellipse.
94 Aside from those below, keyword arguments for the
95 matplotlib.patches.Patch constructor are also accepted
96 ('facecolor', 'linestyle', etc.)
100 axes : `matplotlib.axes.Axes`, optional
101 Axes to plot on. Defaults to matplotlib.pyplot.gca().
102 scale : `float`, optional
103 Scale the displayed ellipse by this factor.
104 show : `bool`, optional
105 If True, update the figure automatically. Set to False for batch
107 rescale : `bool`, optional
108 If True, rescale the axes.
112 interface : `EllipseMatplotlibInterface`
113 An object that allows the matplotlib patch to be updated when the
116 import matplotlib.pyplot
117 interface = self.MatplotlibInterface(self, scale, **kwds)
119 axes = matplotlib.pyplot.gca()
120 axes.add_patch(interface.patch)
122 axes.autoscale_view()
124 axes.figure.canvas.draw()
128Ellipse.MatplotlibInterface = EllipseMatplotlibInterface
129Ellipse.plot = Ellipse_plot
An ellipse core for the semimajor/semiminor axis and position angle parametrization (a,...
update(self, show=True, rescale=True)
__init__(self, ellipse, scale=1.0, **kwds)
Ellipse_plot(self, axes=None, scale=1.0, show=True, rescale=True, **kwds)