lsst.display.matplotlib g2885a5af85+13762949d7
Loading...
Searching...
No Matches
lsst.display.matplotlib.wcsAxes.WcsAxesManager Class Reference

Public Member Functions

 __init__ (self, axes, frameSet, *, grid=False, useSexagesimal=False, extraOptions="")
 draw (self)
 setSexagesimal (self, useSexagesimal)
 remove (self)

Public Attributes

list artists = []

Protected Member Functions

 _plotOptions (self)
 _canvasSize (self)
 _removeArtists (self)
 _onLimitsChanged (self, axes)
 _onResize (self, event)
 _scheduleRedraw (self)
 _redrawNow (self)

Protected Attributes

 _axes = axes
 _frameSet = frameSet
 _grid = grid
 _useSexagesimal = useSexagesimal
 _extraOptions = extraOptions
tuple _savedVisibility
bool _redrawing = False
 _redrawTimer = None
 _renderedSize = None
list _callbackIds
 _resizeCallbackId
 _redrawNow

Static Protected Attributes

int _redrawDelayMs = 200

Detailed Description

Manage AST-drawn sky coordinate axes on a matplotlib Axes.

All visible axis furniture (border, ticks, labels, optional grid)
is drawn by AST; matplotlib's own axis furniture is hidden while
this manager is active and restored by `remove`.

The axes' data coordinates must be pixel coordinates in the LSST
convention, matching the base frame of ``frameSet`` as produced by
`astFrameSetFromWcs`: the center of the first pixel of the parent
image is at (0, 0), and a subimage keeps its parent's coordinates
(its pixel coordinates start at the subimage's XY0, not at zero).
This differs from the FITS convention, in which the first pixel of
the image is centered at (1, 1).

Parameters
----------
axes : `matplotlib.axes.Axes`
    The axes to draw on.
frameSet : `starlink.Ast.FrameSet`
    Pixel-to-sky transform, base frame in axes data coordinates.
grid : `bool`, optional
    Draw the full curvilinear coordinate grid across the image?
useSexagesimal : `bool`, optional
    Format labels as e.g. HH:MM:SS.s rather than decimal degrees.
extraOptions : `str`, optional
    Comma-separated AST Plot attribute settings appended after the
    defaults, so they take precedence (e.g.
    ``"Colour(grid)=2, Width(border)=2"``).

Notes
-----
AST colour values are 1-based indices into the grf colour table
(see `starlink.Grf.grf_matplotlib`), not colour names:
1=default, 2=red, 3=green, 4=blue, 5=cyan, 6=magenta, 7=yellow,
8=black, 9=dark grey, 10=grey, 11=light grey, 12=white.

Member Function Documentation

◆ _canvasSize()

lsst.display.matplotlib.wcsAxes.WcsAxesManager._canvasSize ( self)
protected
Return the current canvas size in device pixels.

◆ _onLimitsChanged()

lsst.display.matplotlib.wcsAxes.WcsAxesManager._onLimitsChanged ( self,
axes )
protected
Schedule a redraw for new view limits; matplotlib callback.

The ``axes`` argument (the axes the callback fired for) is unused.

◆ _onResize()

lsst.display.matplotlib.wcsAxes.WcsAxesManager._onResize ( self,
event )
protected
Schedule a redraw for a new figure size; matplotlib callback.

The ``event`` argument (the resize event) is unused.  Interactive
web backends (e.g. ipympl) emit ``resize_event`` repeatedly at the
size the figure already has, and a redraw repaints the canvas,
which prompts yet another such event; acting on every one produces
an unbounded rebuild loop.  Rebuild only when the canvas has
actually changed size since it was last drawn.

◆ _plotOptions()

lsst.display.matplotlib.wcsAxes.WcsAxesManager._plotOptions ( self)
protected
Return the AST Plot options string for the current state.

◆ _redrawNow()

lsst.display.matplotlib.wcsAxes.WcsAxesManager._redrawNow ( self)
protected
Rebuild the AST axes for the current view and repaint.

◆ _removeArtists()

lsst.display.matplotlib.wcsAxes.WcsAxesManager._removeArtists ( self)
protected
Remove the AST artists from the axes.

◆ _scheduleRedraw()

lsst.display.matplotlib.wcsAxes.WcsAxesManager._scheduleRedraw ( self)
protected
Debounce a rebuild of the AST axes after a view or size change.

The redraw is debounced with a one-shot timer so that a stream of
changes (interactive panning or zooming, the x/y pair from a single
zoom, or a drag-resize) produces a single rebuild once the view
settles.  Backends without a running event loop cannot fire timers,
so there the redraw happens immediately.

◆ draw()

lsst.display.matplotlib.wcsAxes.WcsAxesManager.draw ( self)
Draw (or redraw) the AST axes for the current view limits.

◆ remove()

lsst.display.matplotlib.wcsAxes.WcsAxesManager.remove ( self)
Remove the AST axes and restore matplotlib's axis furniture.

◆ setSexagesimal()

lsst.display.matplotlib.wcsAxes.WcsAxesManager.setSexagesimal ( self,
useSexagesimal )
Switch between sexagesimal and decimal degree labels.

Parameters
----------
useSexagesimal : `bool`
    Format labels as e.g. HH:MM:SS.s iff True.

Member Data Documentation

◆ _callbackIds

list lsst.display.matplotlib.wcsAxes.WcsAxesManager._callbackIds
protected
Initial value:
= [
axes.callbacks.connect("xlim_changed", self._onLimitsChanged),
axes.callbacks.connect("ylim_changed", self._onLimitsChanged),
]

◆ _resizeCallbackId

lsst.display.matplotlib.wcsAxes.WcsAxesManager._resizeCallbackId
protected
Initial value:
= axes.get_figure().canvas.mpl_connect(
"resize_event", self._onResize)

◆ _savedVisibility

tuple lsst.display.matplotlib.wcsAxes.WcsAxesManager._savedVisibility
protected
Initial value:
= (
axes.xaxis.get_visible(),
axes.yaxis.get_visible(),
{name: spine.get_visible() for name, spine in axes.spines.items()},
)

The documentation for this class was generated from the following file:
  • python/lsst/display/matplotlib/wcsAxes.py