Closed ManonMarchand closed 9 months ago
See EllipticalFrame
implementation here
class EllipticalFrame(BaseFrame):
"""
An elliptical frame.
"""
spine_names = "chv"
def update_spines(self):
xmin, xmax = self.parent_axes.get_xlim()
ymin, ymax = self.parent_axes.get_ylim()
xmid = 0.5 * (xmax + xmin)
ymid = 0.5 * (ymax + ymin)
dx = xmid - xmin
dy = ymid - ymin
theta = np.linspace(0.0, 2 * np.pi, 1000)
self["c"].data = np.array(
[xmid + dx * np.cos(theta), ymid + dy * np.sin(theta)]
).transpose()
self["h"].data = np.array(
[np.linspace(xmin, xmax, 1000), np.repeat(ymid, 1000)]
).transpose()
self["v"].data = np.array(
[np.repeat(xmid, 1000), np.linspace(ymin, ymax, 1000)]
).transpose()
super().update_spines()
def _update_patch_path(self):
"""Override path patch to include only the outer ellipse,
not the major and minor axes in the middle.
"""
self.update_spines()
vertices = self["c"].data
if self._path is None:
self._path = Path(vertices)
else:
self._path.vertices = vertices
def draw(self, renderer):
"""Override to draw only the outer ellipse,
not the major and minor axes in the middle.
FIXME: we may want to add a general method to give the user control
over which spines are drawn.
"""
axis = "c"
pixel = self[axis]._get_pixel()
line = Line2D(
pixel[:, 0],
pixel[:, 1],
linewidth=self._linewidth,
color=self._color,
zorder=1000,
)
line.draw(renderer)
In all-sky plots, we draw a rectangular frame instead of an elliptical one, see MNWE:
However this is not as trivial as enforcing Elliptical Frame, see:
There is something to investigate, don't know if the bug is upstream in astropy or with us.