# Roi¶

class glue.core.roi.Roi[source]

Bases: `object`

A geometrical 2D region of interest.

Glue uses ROIs to represent user-drawn regions on plots. There are many specific sub-classes of Roi, but they all have a `contains` method to test whether a collection of 2D points lies inside the region. ROI bounds are generally designed as being exclusive (that is, points situated exactly on a border are considered to lie outside the region).

Methods Summary

 Return the (x, y) coordinates of the ROI center `contains`(x, y) Test which of a set of (x, y) points fall within the region of interest. `contains3d`(x, y, z) Test which of a set of projected (x, y, z) points fall within the linked 2D region of interest. Return a clone of the Roi Returns True if the ROI is defined `move_to`(x, y) Translate the ROI to a center of (x, y) `rotate_by`(dtheta, **kwargs) Rotate the Roi around center by angle dtheta. `rotate_to`(theta) Rotate anticlockwise around center to position angle theta. Returns vertices vx, vy of a polygon approximating the Roi, where each is an array of vertex coordinates in x and y. `transformed`([xfunc, yfunc]) A transformed version of the Roi

Methods Documentation

center()[source]

Return the (x, y) coordinates of the ROI center

contains(x, y)[source]

Test which of a set of (x, y) points fall within the region of interest.

Parameters:
xfloat or array-like

x coordinate(s) of point(s).

yfloat or array-like

y coordinate(s) of point(s).

Returns:
insidebool or ~numpy.ndarray

An boolean iterable, where each element is True if the corresponding (x, y) tuple is inside the Roi.

Raises:
UndefinedROI

If not defined.

contains3d(x, y, z)[source]

Test which of a set of projected (x, y, z) points fall within the linked 2D region of interest.

Parameters:
x`ndarray`

Array of x locations

y`ndarray`

Array of y locations

z`ndarray`

Array of z locations

Returns:
`ndarray`

A boolean array, where each element is True if the corresponding (x, y, z) tuple is projected inside the associated 2D Roi.

Raises:
UndefinedROI

If not defined.

copy()[source]

Return a clone of the Roi

defined()[source]

Returns True if the ROI is defined

move_to(x, y)[source]

Translate the ROI to a center of (x, y)

rotate_by(dtheta, **kwargs)[source]

Rotate the Roi around center by angle dtheta.

Parameters:
dthetafloat

Change in anticlockwise rotation angle around center in radian.

rotate_to(theta)[source]

Rotate anticlockwise around center to position angle theta.

Parameters:
thetafloat

Angle of anticlockwise rotation around center in radian.

to_polygon()[source]

Returns vertices vx, vy of a polygon approximating the Roi, where each is an array of vertex coordinates in x and y.

transformed(xfunc=None, yfunc=None)[source]

A transformed version of the Roi