chaco.base_1d_plot module

Abstract base class for 1-D plots which only use one axis

class chaco.base_1d_plot.Base1DPlot(**traits)

Bases: chaco.abstract_plot_renderer.AbstractPlotRenderer

Base class for one-dimensional plots

This class provides a base for plots such as jitter plots, color bars, single-axis scatter plots, and geophysical horizon and tops plots.

direction = Enum("normal", "flipped")

Should the plot go left-to-right or bottom-to-top (normal) or the reverse?

index = Instance(ArrayDataSource)

The data source of values

index_mapper = Instance(AbstractMapper)

Screen mapper for index data.

index_range = Property(depends_on="index_mapper.range")

Convenience property for accessing the data range of the mapper.

map_data(screen_pts)

Maps 2D screen space points into the 1D index space of the plot.

Parameters

screen_pts (tuple of x-array, y-array) – 2 arrays (or values) screen space coordinates.

Returns

data_array – An array of points in data space corresponding to the screen-space points.

Return type

1D array

map_index(screen_pt, threshold=2.0, outside_returns_none=True, index_only=True)

Maps a screen space point to an index into the plot’s index array.

Parameters
  • screen_pts (tuple of x-array, y-array) – 2 arrays (or values) screen space coordinates.

  • threshold (float) – Optional screen-space distance allowed between screen_pt and the plot; if non-zero, then a screen_pt within this distance is mapped to the neared plot index. (This feature is useful for sparse data.)

  • outside_returns_none (Boolean) – If True, then if screen_pt is outside the range of the data, the method returns None. If False, it returns the nearest end index in such a case.

  • index_only (Boolean) – This is included for compatibity with the base class, but is ignored, as it is always true for 1D plots.

Returns

index – An index into the index array. If the input point cannot be mapped to an index, then None is returned.

If screen_pt corresponds to multiple indices, then only the first index is returned.

Return type

int

map_screen(data_array)

Maps a 1D array of data points into screen space and returns it as a 1D array.

Parameters

data_array (1D array) – An array of data-space values to be mapped to screen coordinates.

Returns

screen_array – An array of points in screen space, either x-values (if orientation is ‘h’) or y-values (if orientation is ‘v’).

Return type

1D array

Notes

Returning a 1D array is experimental, and may break some tools and overlays. If needs be we can refactor so that it returns a 2D array.

orientation = Enum("v", "h")

The orientation of the index axis.

origin = Property(

Faux origin for the axes and other objects to look at

x_mapper = Property(observe=["orientation", "index_mapper"])

Corresponds to either index_mapper or None, depending on the orientation of the plot.

y_mapper = Property(observe=["orientation", "index_mapper"])

Corresponds to either index_mapper or None, depending on the orientation of the plot.