TextPixelRegion

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

Bases: regions.shapes.point.PointPixelRegion

A text string in pixel coordinates.

Parameters
centerPixCoord

The leftmost point of the text string before rotation.

textstr

The text string.

metaRegionMeta, optional

A dictionary that stores the meta attributes of this region.

visualRegionVisual, optional

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

Examples

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

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

center = PixCoord(x=15, y=10)
visual = RegionVisual({'textangle': 30})
reg = TextPixelRegion(center=center, text="Hello World!",
                      visual=visual)
reg.plot(ax=ax)

ax.set_xlim(10, 30)
ax.set_ylim(2.5, 20)
ax.set_aspect('equal')

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

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

Attributes Summary

center

The leftmost pixel position (before rotation) as a PixCoord.

Methods Summary

as_artist([origin])

Return a matplotlib Text object for this region (matplotlib.text.Text).

to_sky(wcs)

Return a region defined in sky coordinates.

Attributes Documentation

center

The leftmost pixel position (before rotation) as a PixCoord.

Methods Documentation

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

Return a matplotlib Text object for this region (matplotlib.text.Text).

Parameters
originarray_like, optional

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

**kwargsdict

Any keyword arguments accepted by Text. These keywords will override any visual meta attributes of this region.

Returns
artistText

A matplotlib Text object.

to_sky(wcs)[source]

Return a region defined in sky coordinates.

Parameters
wcsWCS

The world coordinate system transformation to use to convert from pixels to sky coordinates.

Returns
sky_regionSkyRegion

The sky region.