Skip to content

Plot region exported from CARTA #577

Description

@HealthyPear

I created a region file from CARTA v4.1.0 and I want to superimpose it to a radio map which "I load from FITS and from which I get the WCS.

What I am doing is this,

fig, ax = plt.subplots(subplot_kw={"projection": radio_data_wcs})

template_region = Regions.read("my_carta_region", format="crtf").regions[0]

pixel_region = template_region.to_pixel(radio_data_wcs)
pixel_region.plot()

plt.show()

I get the following error,

Traceback (most recent call last):
  File "plot_region_over_radio_data.py", line 47, in <module>
    pixel_region.plot()
  File "xxx/python3.12/site-packages/regions/core/core.py", line 446, in plot
    artist = self.as_artist(origin=origin, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "xxx/python3.12/site-packages/regions/shapes/ellipse.py", line 209, in as_artist
    return Ellipse(xy=xy, width=width, height=height, angle=angle,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "xxx/python3.12/site-packages/matplotlib/patches.py", line 1542, in __init__
    super().__init__(**kwargs)
  File "xxx/python3.12/site-packages/matplotlib/patches.py", line 83, in __init__
    self.set_edgecolor(edgecolor)
  File "xxx/python3.12/site-packages/matplotlib/patches.py", line 338, in set_edgecolor
    self._set_edgecolor(color)
  File "xxx/python3.12/site-packages/matplotlib/patches.py", line 324, in _set_edgecolor
    self._edgecolor = colors.to_rgba(color, self._alpha)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "xxx/python3.12/site-packages/matplotlib/colors.py", line 302, in to_rgba
    rgba = _to_rgba_no_colorcycle(c, alpha)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "xxx/python3.12/site-packages/matplotlib/colors.py", line 384, in _to_rgba_no_colorcycle
    raise ValueError(f"Invalid RGBA argument: {orig_c!r}")
ValueError: Invalid RGBA argument: '2ee6d6'

If I assume 2ee6d6 is the ID for an hex color, I attempt to specify the color with the proper # suffix and I get a new error,

Traceback (most recent call last):
  File "plot_region_over_radio_data.py", line 47, in <module>
    pixel_region.plot(edgecolor="#2ee6d6")
  File "xxx/python3.12/site-packages/regions/core/core.py", line 446, in plot
    artist = self.as_artist(origin=origin, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "xxx/python3.12/site-packages/regions/shapes/ellipse.py", line 209, in as_artist
    return Ellipse(xy=xy, width=width, height=height, angle=angle,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "xxx/site-packages/matplotlib/patches.py", line 1542, in __init__
    super().__init__(**kwargs)
  File "xxx/python3.12/site-packages/matplotlib/patches.py", line 98, in __init__
    self._internal_update(kwargs)
  File "xxx/site-packages/matplotlib/artist.py", line 1219, in _internal_update
    return self._update_props(
           ^^^^^^^^^^^^^^^^^^^
  File "xxx/python3.12/site-packages/matplotlib/artist.py", line 1193, in _update_props
    raise AttributeError(
AttributeError: Ellipse.set() got an unexpected keyword argument 'symsize'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions