overplotting scatter points onto e.g. density plot

8 views
Skip to first unread message

Aaron Bryant

unread,
Sep 28, 2023, 8:49:42 AM9/28/23
to PDR Toolbox
Hi Marc,

I am attempting to overplot scatter points for individual spatial pixels onto plots such as the density, radiation field, reduced_chisq maps. I am attempting this like so:

lrp.density()
lrp._plt.scatter(x, y, marker='x', s=250)

but the scatter point does not appear. I have tried numerous combinations of x & y in both pixel coordinates and ra/dec decimal degrees. Such overplotting works fine for e.g. lrp.overlay_all_ratios when specifying a scatter point in n(H)-G0 space. But not here. Are there paticular units that should be specified for the scatter point? I have a skycoord object for every desired scatter point. I already tried skycoord.ra/dec.degree & skycoord.ra/dec.hour

thanks,
Aaron

Marc W. Pound

unread,
Sep 28, 2023, 12:17:47 PM9/28/23
to Aaron Bryant, PDR Toolbox
Hi Aaron,

Have you tried applying a transform in the argument to scatter() when using SkyCoords?  See https://docs.astropy.org/en/stable/visualization/wcsaxes/overlays.html in the section World Coordinates.   You may have to use lpr._plot.gca().scatter() to get the axis version if plt.scatter does not support the transform keyword.
Let me know if that works.
Marc


--
You received this message because you are subscribed to the Google Groups "PDR Toolbox" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pdrt+uns...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pdrt/9f1c9b4f-e983-4d5a-8440-de6f2c387acen%40googlegroups.com.


--
Dr. Marc Pound
Research Scientist
Astronomy Department
University of Maryland, College Park

Aaron Bryant

unread,
Oct 4, 2023, 9:02:23 AM10/4/23
to PDR Toolbox
Hi Marc,

thanks for the reply. 

following your suggestion I receive the following error:

r.lrp.density(contours=False, norm = 'log', colorbar = True)
r.lrp._plt.gca().scatter(skyorigin.ra.degree, skyorigin.dec.degree, c = 'red',  marker = 'x', s = 250, linewidths = 5, transform = r.lrp._plt.gca().get_transform('world'))
Traceback (most recent call last):

  Input In [9] in <cell line: 2>
    r.lrp._plt.gca().scatter(skyorigin.ra.degree, skyorigin.dec.degree, c = 'red',  marker = 'x', s = 250, linewidths = 5, transform = r.lrp._plt.gca().get_transform('world'))

TypeError: get_transform() takes 1 positional argument but 2 were given


r is just a wrapper object for the pdr run

using a proxy like

ax = r.lrp._plt.gca()
ax.scatter(skyorigin.ra.degree, skyorigin.dec.degree, c  = 'red',  marker = 'x', s = 250, linewidths = 5, transform = ax.get_transform('world'))

similarly doesnt work.

Apologies if this is a pythonically-stupid question.

Regards,
Aaron

Marc W. Pound

unread,
Oct 4, 2023, 1:30:01 PM10/4/23
to Aaron Bryant, PDR Toolbox
Hi Aaron

This seems to be a difference between matplotlib's Axes and astropy's WCSAxes.   The former has no arguments to get_transform while the latter takes the string argument like you had.    This will require a bit of poking to figure out; I would have thought that the plot axes in this case would be WCSAxes.

Marc


Reply all
Reply to author
Forward
0 new messages