chaco.grid module

Defines the PlotGrid class, and associated TraitsUI View and validator function.

class chaco.grid.PlotGrid(**traits)

Bases: chaco.abstract_overlay.AbstractOverlay

An overlay that represents a grid.

A grid is a set of parallel lines, horizontal or vertical. You can use multiple grids with different settings for the horizontal and vertical lines in a plot.

data_max = Optional(Float)

The dataspace value at which to end this grid. If None, then uses the mapper.range.high.

data_min = Optional(Float)

The dataspace value at which to start this grid. If None, then uses the mapper.range.low.

do_layout(*args, **kw)

Tells this component to do layout at a given size.

Overrides PlotComponent.

flip_axis = Bool(False)

Draw the ticks starting at the end of the mapper range? If False, the ticks are drawn starting at 0. This setting can be useful to keep the grid from from “flashing” as the user resizes the plot area.

grid_interval = Union(Constant("auto"), Float)

The dataspace interval between grid lines.


Invalidate cached information about the grid.

line_color = black_color_trait

The color of the grid lines.

line_style = LineStyle("solid")

The style (i.e., dash pattern) of the grid lines.

line_width = CInt(1)

The thickness, in pixels, of the grid lines.

mapper = Instance(AbstractMapper)

The mapper (and associated range) that drive this PlotGrid.


Event handler that is bound to this mapper’s updated event.

orientation = Enum("horizontal", "vertical")

The orientation of the grid lines. “horizontal” means that the grid lines are parallel to the X axis and the ticker and grid interval refer to the Y axis.

overlay(other_component, gc, view_bounds=None, mode='normal')

Draws this component overlaid on another component.

Overrides AbstractOverlay.

resizable = "hv"

Dimensions that the grid is resizable in (overrides PlotComponent).

tick_generator = Instance(AbstractTickGenerator)

A callable that implements the AbstractTickGenerator Interface.


Default TraitsUI View for modifying grid attributes.

transverse_bounds = Union(None, Tuple, Callable)

Optional specification of the grid bounds in the dimension transverse to the ticking/gridding dimension, i.e. along the direction specified by self.orientation. If this is specified but transverse_mapper is not specified, then there is no effect.

None : use self.bounds or self.component.bounds (if overlay) Tuple : (low, high) extents, used for every grid line Callable : Function that takes an array of dataspace grid ticks

and returns either an array of shape (N,2) of (starts,ends) for each grid point or a single tuple (low, high)

transverse_mapper = Instance(AbstractMapper)

Mapper in the direction corresponding to self.orientation, i.e. transverse to the direction of self.mapper. This is used to compute the screen position of transverse_bounds. If this is not specified, then transverse_bounds has no effect, and vice versa.


Called when an attribute that affects the appearance of the grid is changed.


Validator function that returns val if val is either a number or the word ‘auto’. This is used as a validator for the text editor in the traits UI for the tick_interval trait.