23 """lsst.afw.geom.ellipses
25 from .ellipsesLib
import *
28 (Distortion, DeterminantRadius): SeparableDistortionDeterminantRadius,
29 (Distortion, TraceRadius): SeparableDistortionTraceRadius,
30 (Distortion, LogDeterminantRadius): SeparableDistortionLogDeterminantRadius,
31 (Distortion, LogTraceRadius): SeparableDistortionLogTraceRadius,
32 (ConformalShear, DeterminantRadius): SeparableConformalShearDeterminantRadius,
33 (ConformalShear, TraceRadius): SeparableConformalShearTraceRadius,
34 (ConformalShear, LogDeterminantRadius): SeparableConformalShearLogDeterminantRadius,
35 (ConformalShear, LogTraceRadius): SeparableConformalShearLogTraceRadius
40 """An interface for drawing the ellipse using matplotlib.
42 This is typically initiated by calling Ellipse.plot(), which
43 returns an instance of this class.
46 def __init__(self, ellipse, scale=1.0, **kwds):
47 import matplotlib.patches
53 core.scale(2.0 * scale)
54 self.
patch = matplotlib.patches.Ellipse(
56 core.getA(), core.getB(), core.getTheta() * 180.0 / np.pi,
61 return getattr(self.
patch, name)
63 def update(self, show=True, rescale=True):
64 """Update the matplotlib representation to the current ellipse parameters.
66 import matplotlib.patches
68 core = _agl.Axes(self.
__ellipse.getCore())
69 core.scale(2.0 * scale)
70 new_patch = matplotlib.patches.Ellipse(
72 core.a, core.b, core.theta * 180.0 / np.pi
74 new_patch.update_from(self.
patch)
75 axes = self.
patch.get_axes()
78 axes.add_patch(new_patch)
79 self.
patch = new_patch
84 axes.figure.canvas.draw()
87 def Ellipse_plot(self, axes=None, scale=1.0, show=True, rescale=True, **kwds):
88 """Plot the ellipse in matplotlib, adding a MatplotlibInterface
89 object as the 'matplotlib' attribute of the ellipse.
91 Aside from those below, keyword arguments for the
92 matplotlib.patches.Patch constructor are also accepted
93 ('facecolor', 'linestyle', etc.)
97 axes : `matplotlib.axes.Axes`, optional
98 Axes to plot on. Defaults to matplotlib.pyplot.gca().
99 scale : `float`, optional
100 Scale the displayed ellipse by this factor.
101 show : `bool`, optional
102 If True, update the figure automatically. Set to False for batch
104 rescale : `bool`, optional
105 If True, rescale the axes.
109 interface : `EllipseMatplotlibInterface`
110 An object that allows the matplotlib patch to be updated when the
113 import matplotlib.pyplot
114 interface = self.MatplotlibInterface(self, scale, **kwds)
116 axes = matplotlib.pyplot.gca()
117 axes.add_patch(interface.patch)
119 axes.autoscale_view()
121 axes.figure.canvas.draw()
125 Ellipse.MatplotlibInterface = EllipseMatplotlibInterface
126 Ellipse.plot = Ellipse_plot