Mappers

AbstractMapper

class enthought.chaco.api.AbstractMapper

Bases: enthought.traits.has_traits.HasTraits

Defines an abstract mapping from a region in input space to a region in output space.

Traits:

updated : Event

A generic “update” event that generally means that anything that relies on this mapper for visual output should do a redraw or repaint.

map_data(screen_val)

map_data(screen_val) -> data_val

Maps values from screen space into data space.

map_data_array(screen_vals)

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_array)

map_screen(data_array) -> screen_array

Maps values from data space into screen space.

Base1DMapper

class enthought.chaco.api.Base1DMapper

Bases: enthought.chaco.abstract_mapper.AbstractMapper

Defines an abstract mapping from a 1-D region in input space to a 1-D region in output space.

Traits:

range : Instance(DataRange1D)

The data-space bounds of the mapper.

low_pos : Float(0.0)

The screen space position of the lower bound of the data space.

high_pos : Float(1.0)

The screen space position of the upper bound of the data space.

screen_bounds : Property

Convenience property to get low and high positions in one structure. Must be a tuple (low_pos, high_pos).

LinearMapper

class enthought.chaco.api.LinearMapper

Bases: enthought.chaco.base_1d_mapper.Base1DMapper

Maps a 1-D data space to and from screen space by specifying a range in data space and a corresponding fixed line in screen space.

This class concerns itself only with metric and not with orientation. So, to “flip” the screen space orientation, simply swap the values for low_pos and high_pos.

map_data(screen_val)

map_data(screen_val) -> data_val

Overrides AbstractMapper. Maps values from screen space into data space.

map_data_array(screen_vals)

map_data_array(screen_vals) -> data_vals

Overrides AbstractMapper. Maps an array of values from screen space into data space.

map_screen(data_array)

map_screen(data_array) -> screen_array

Overrides AbstractMapper. Maps values from data space into screen space.

LogMapper

class enthought.chaco.api.LogMapper

Bases: enthought.chaco.base_1d_mapper.Base1DMapper

Defines a 1-D logarithmic scale mapping from a 1-D region in input space to a 1-D region in output space.

Traits:

fill_value : Float(1.0)

The value to map when asked to map values <= LOG_MINIMUM to screen space.

map_data(screen_val)

map_data(screen_val) -> data_val

Overrides Abstract Mapper. Maps values from screen space into data space.

map_screen(data_array)

map_screen(data_array) -> screen_array

Overrides AbstractMapper. Maps values from data space to screen space.

GridMapper

class enthought.chaco.api.GridMapper(x_type='linear', y_type='linear', **kwargs)

Bases: enthought.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.

Traits:

range : Instance(DataRange2D)

The data-space bounds of the mapper.

x_low_pos : Float(0.0)

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

x_high_pos : Float(1.0)

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

y_low_pos : Float(0.0)

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

y_high_pos : Float(1.0)

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

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).

map_data(screen_pts)

map_data(screen_pts) -> data_vals

Maps values from screen space into data space.

map_screen(data_pts)

map_screen(data_pts) -> screen_array

Maps values from data space into screen space.