chaco.grid_mapper module

Defines the GridMapper class, which maps from a 2-D region in data space into a structured (gridded) 1-D output space.

class chaco.grid_mapper.GridMapper(x_type='linear', y_type='linear', range=None, **kwargs)

Bases: chaco.abstract_mapper.AbstractMapper

Maps a 2-D data space to and from screen space by specifying a 2-tuple in data space or by specifying a pair of screen coordinates.

The mapper concerns itself only with metric and not with orientation. So, to “flip” a screen space orientation, swap the appropriate screen space values for x_low_pos, x_high_pos, y_low_pos, and y_high_pos.

aspect_ratio = Float(1.0)

The aspect ratio that we wish to maintain

maintain_aspect_ratio = Bool

Should the mapper try to maintain a fixed aspect ratio between x and y

map_data(screen_pts)data_vals

Maps values from screen space into data space.

map_data_array(screen_vals)data_vals

Maps an array of values from screen space into data space. By default, this method just loops over the points, calling map_data() on each one. For vectorizable mapping functions, override this implmentation with a faster one.

map_screen(data_pts)screen_array

Maps values from data space into screen space.

range = Instance(DataRange2D)

The data-space bounds of the mapper.

screen_bounds = Property

Convenience property for low and high positions in one structure. Must be a tuple (x_low_pos, x_high_pos, y_low_pos, y_high_pos).

stretch_data_x = DelegatesTo("_xmapper", prefix="stretch_data")

Should the mapper stretch the dataspace when its screen space bounds are modified (default), or should it preserve the screen-to-data ratio and resize the data bounds? If the latter, it will only try to preserve the ratio if both screen and data space extents are non-zero.

x_high_pos = Float(1.0)

The screen space position of the upper bound of the horizontal axis.

x_low_pos = Float(0.0)

The screen space position of the lower bound of the horizontal axis.

y_high_pos = Float(1.0)

The screen space position of the upper bound of the vertical axis.

y_low_pos = Float(0.0)

The screen space position of the lower bound of the vertical axis.