Skip to content

Feature request: Handle WCS projections for plotting astronomical images. #606

@astrogewgaw

Description

@astrogewgaw

Currently, it seems that plotting with WCS does not work in UltraPlot. Here is a minimal working example:

import ultraplot as uplt
from astropy.coordinates import SkyCoord

coords = SkyCoord("04h30m49.1s +64d50m53.0s")

fig = uplt.figure()
ax = fig.add_axes([0.1,0.1,0.85,0.85], projection=mosaic.wcs)
ax.plot(
    coords.ra,
    coords.dec,
    ".",
    transform=ax.get_transform("icrs"),
    mec="b",
    mfc="none",
)
uplt.show()

This raises the following error:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[13], line 11
      5 fig = uplt.figure()
      6 ax = fig.add_axes([0.1,0.1,0.85,0.85], projection=mosaic.wcs)
      7 ax.plot(
      8     coords.ra,
      9     coords.dec,
     10     ".",
---> 11     transform=ax.get_transform("icrs"),
     12     mec="b",
     13     mfc="none",
     14 )
     15 uplt.show()

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

Using Matplotlib, this works:

import matplotlib.pyplot as plt
from astropy.coordinates import SkyCoord

coords = SkyCoord("04h30m49.1s +64d50m53.0s")

fig = plt.figure(1)
ax = fig.add_axes([0.1,0.1,0.85,0.85], projection=mosaic.wcs)
ax.plot(
    beam.ra,
    beam.dec,
    ".",
    transform=ax.get_transform("icrs"),
    mec="b",
    mfc="none",
)
plt.show()

I am assuming that UltraPlot cannot handle WCS projections, hence this issue is framed as a feature request. As far as I am aware, UltraPlot has a lot of features focused on plotting geographical data. It would be great if features related to plotting astronomical data and images could also be added, especially since many of the plots we make are quite similar to ones made for geographical data.

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions