Skip to content

Commit 6ab80cf

Browse files
committed
Add outline_sigmas argument to plot and plot scatters on top of axes
1 parent 16238fb commit 6ab80cf

File tree

1 file changed

+26
-8
lines changed

1 file changed

+26
-8
lines changed

hpmoc/plot.py

+26-8
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,8 @@ def plot(
624624
missing_color: Optional[Union[str, Tuple[int, int, int]]] = None,
625625
nan_color: Optional[Union[str, Tuple[int, int, int]]] = None,
626626
alpha: float = 1.,
627-
sigmas: Iterable[float] = (1,),
627+
sigmas: Iterable[float] = [],
628+
outline_sigmas: Iterable[float] = [],
628629
scatter_labels: Union[bool, dict] = True,
629630
ax: Optional[Union[
630631
'astropy.visualization.wcsaxes.WCSAxes',
@@ -718,6 +719,9 @@ def plot(
718719
sigmas: Iterable[float], optional
719720
The size of the error region about each point source to plot in units
720721
of its error parameter sigma.
722+
outline_sigmas: Iterable[float], optional
723+
The size of the error region about each point source to plot as an
724+
unfilled circle in units of its error parameter sigma.
721725
scatter_labels: bool, optional
722726
Whether to show labels for the scattered points. If ``True``, display
723727
either their labels (if defined) or their indices within the
@@ -852,7 +856,7 @@ def plot(
852856
from matplotlib.transforms import ScaledTranslation
853857
from matplotlib.gridspec import SubplotSpec
854858
from astropy.coordinates.sky_coordinate import SkyCoord
855-
from astropy.visualization.wcsaxes import WCSAxes
859+
from astropy.visualization.wcsaxes import WCSAxes, SphericalCircle
856860
from astropy.visualization.wcsaxes.frame import (
857861
RectangularFrame,
858862
EllipticalFrame,
@@ -962,11 +966,6 @@ def plot(
962966
transform = ax.get_transform('world')
963967
label_transform = transform + ScaledTranslation(N_X_OFFSET/2, N_Y_OFFSET/2,
964968
ax.figure.dpi_scale_trans)
965-
for pts in scatter:
966-
cm = pts.cmap()
967-
for sigma in sigmas:
968-
ax.imshow(pts.render(projection, extent=sigma), vmin=0, vmax=1,
969-
cmap=cm)
970969
for pts in scatter:
971970
# Skip pts if it is empty, since you cannot have empty SkyCoords
972971
if not pts.points:
@@ -980,7 +979,25 @@ def plot(
980979
include &= (pts_y < ax.wcs.pixel_shape[1]+.5) & (pts_y > .5)
981980
col = pts.rgba.to_hex(False)
982981
ax.scatter(pts_x[include], pts_y[include], c=col, marker=pts.marker,
983-
s=scatter_marker_size, label=pts.label, path_effects=outline)
982+
s=scatter_marker_size, label=pts.label, path_effects=outline,
983+
zorder=10)
984+
985+
# plot the shaded error circles, if needed
986+
cm = pts.cmap()
987+
for sigma in sigmas:
988+
ax.imshow(pts.render(projection, extent=sigma), vmin=0, vmax=1,
989+
cmap=cm, zorder=5)
990+
991+
# plot the error circle outlines, if needed
992+
for outline_sigma in outline_sigmas:
993+
for ra, dec, sigma, _ in pts.points:
994+
coord = SkyCoord(ra * deg, dec * deg)
995+
s = SphericalCircle(coord, sigma * outline_sigma * deg,
996+
edgecolor=col, facecolor='none',
997+
transform=ax.get_transform('icrs'), zorder=5)
998+
ax.add_patch(s)
999+
1000+
# plot the scatter labels, if needed
9841001
if scatter_labels:
9851002
for i, (r, d, *sl) in enumerate(pts.points):
9861003
if not include[i]:
@@ -995,6 +1012,7 @@ def plot(
9951012
'color': col,
9961013
'va': 'bottom',
9971014
'ha': 'left',
1015+
'zorder': 15
9981016
}
9991017
if not isinstance(scatter_labels, bool):
10001018
kw.update(scatter_labels)

0 commit comments

Comments
 (0)