regions icon indicating copy to clipboard operation
regions copied to clipboard

`CompoundPixelRegion.plot()` needs center

Open robelgeda opened this issue 3 years ago • 0 comments

Issue when trying to plot a compound region:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Input In [66], in <cell line: 2>()
     68 chip_pixel_region = chip_region.to_pixel(wcs=wcs)
---> 69 chip_pixel_region.plot(fc='None', ec='blue', label=f"{region_catalog}", lw=4)

File ~/miniconda3/envs/astroconda/lib/python3.9/site-packages/regions/core/core.py:406, in PixelRegion.plot(self, origin, ax, **kwargs)
    403 if ax is None:
    404     ax = plt.gca()
--> 406 artist = self.as_artist(origin=origin, **kwargs)
    407 ax.add_artist(artist)
    409 return artist

File ~/miniconda3/envs/astroconda/lib/python3.9/site-packages/regions/core/compound.py:146, in CompoundPixelRegion.as_artist(self, origin, **kwargs)
    126 def as_artist(self, origin=(0, 0), **kwargs):
    127     """
    128     Return a matplotlib patch object for this region
    129     (`matplotlib.patches.PathPatch`).
   (...)
    144         A matplotlib patch object.
    145     """
--> 146     if (self.region1.center == self.region2.center
    147             and self.operator is op.xor):
    149         import matplotlib.patches as mpatches
    151         # set mpl_kwargs before as_artist is called on region1 and
    152         # region2

AttributeError: 'CompoundPixelRegion' object has no attribute 'center'

Region was made by taking the union of multiple regions

robelgeda avatar Jul 14 '22 17:07 robelgeda