TextPixelRegion

class regions.TextPixelRegion(center, text, meta=None, visual=None)[source]

Bases: regions.PointPixelRegion

A Text string in pixel coordinates

Parameters:
center : PixCoord

The position of the leftmost point of the text string

text : str

The text string.

meta : RegionMeta object, optional

A dictionary which stores the meta attributes of this region.

visual : RegionVisual object, optional

A dictionary which stores the visual meta attributes of this region.

Examples

from regions import PixCoord, TextPixelRegion, RegionVisual
import matplotlib.pyplot as plt

x, y = 15, 10
textangle = '30'

fig, ax = plt.subplots(1, 1)

center = PixCoord(x=x, y=y)
reg = TextPixelRegion(center=center, text="Hello World!",
                      visual=RegionVisual(textangle=textangle))
reg.plot(ax=ax)

plt.xlim(10, 30)
plt.ylim(2.5, 20)
ax.set_aspect('equal')

(Source code, png, hires.png, pdf)

../_images/regions-TextPixelRegion-1.png

Methods Summary

as_artist(self[, origin]) Matplotlib Text object for this region (matplotlib.text.Text).
to_sky(self, wcs) Returns a region defined in sky coordinates.

Methods Documentation

as_artist(self, origin=(0, 0), **kwargs)[source]

Matplotlib Text object for this region (matplotlib.text.Text).

Parameters:
origin : array_like, optional

The (x, y) pixel position of the origin of the displayed image. Default is (0, 0).

kwargs : dict

All keywords that a Text object accepts

Returns:
text : Text

Matplotlib Text object.

to_sky(self, wcs)[source]

Returns a region defined in sky coordinates.

Parameters:
wcs : WCS instance

The world coordinate system transformation to assume

Returns:
sky_region : SkyRegion object.