chaco.axis module

Defines the PlotAxis class, and associated validator and UI.

class chaco.axis.MinorPlotAxis(*args, **kwargs)

Bases: chaco.axis.PlotAxis

The MinorPlotAxis is a PlotAxis which draws ticks with a smaller interval, smaller tick sizes, and no tick labels.

class chaco.axis.PlotAxis(component=None, **kwargs)

Bases: chaco.abstract_overlay.AbstractOverlay

The PlotAxis is a visual component that can be rendered on its own as a standalone component or attached as an overlay to another component. (To attach it as an overlay, set its component attribute.)

When it is attached as an overlay, it draws into the padding around the component.

axis_line_color = ColorTrait("black")

The color of the axis line.

axis_line_style = LineStyle("solid")

The dash style of the axis line.

axis_line_visible = Bool(True)

Is the axis line visible?

axis_line_weight = Float(1.0)

The line thickness (in pixels) of the axis line.

bgcolor = ColorTrait("transparent")

Background color (overrides AbstractOverlay). Axes usually let the color of the container show through.

ensure_labels_bounded = Bool(False)

Does the axis ensure that its end labels fall within its bounding area?

ensure_ticks_bounded = Bool(False)

Does the axis prevent the ticks from being rendered outside its bounds? This flag is off by default because the standard axis does render ticks that encroach on the plot area.


Invalidates the pre-computed layout and scaling data.

mapper = Instance(AbstractMapper)

The mapper that drives this axis.


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

orientation = Enum("top", "bottom", "left", "right")

The location of the axis relative to the plot. This determines where the axis title is located relative to the axis line.

origin = Enum("bottom left", "top left", "bottom right", "top right")

Keep an origin for plots that aren’t attached to a component

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

Draws this component overlaid on another component.

Overrides AbstractOverlay.

resizable = "hv"

Dimensions that the axis is resizable in (overrides PlotComponent). Typically, axes are resizable in both dimensions.

small_haxis_style = Bool(False)

A special version of the axis line that is more useful for geophysical plots.

tick_color = ColorTrait("black")

The color of the ticks.

tick_generator = Instance(AbstractTickGenerator)

A callable that implements the AbstractTickGenerator interface.

tick_in = Int(5)

The number of pixels by which the ticks extend into the plot area.

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

The dataspace interval between ticks.

tick_label_alignment = Enum("edge", "corner")

Whether to align to corners or edges (corner is better for 45 degree rotation)

tick_label_color = ColorTrait("black")

The color of the tick labels.

tick_label_font = KivaFont("modern 10")

The font of the tick labels.

tick_label_formatter = Callable(DEFAULT_TICK_FORMATTER)

A callable that is passed the numerical value of each tick label and that returns a string.

tick_label_margin = Int(2)

The margin around the tick labels.

tick_label_offset = Float(8.0)

The distance of the tick label from the axis.

tick_label_position = Enum("outside", "inside")

Whether the tick labels appear to the inside or the outside of the plot area

tick_label_rotate_angle = Float(0)

The rotation of the tick labels.

tick_out = Int(5)

The number of pixels by which the ticks extend into the label area.

tick_visible = Bool(True)

Are ticks visible at all?

tick_weight = Float(1.0)

The thickness (in pixels) of each tick.

title = Str()  # May want to add PlotLabel option

The text of the axis title.

title_angle = Float(0.0)

The angle of the title, in degrees, from horizontal line

title_color = ColorTrait("black")

The color of the title.

title_font = KivaFont("modern 12")

The font of the title.

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

The spacing between the axis line and the title


Returns a View instance for use with TraitsUI. This method is called automatically be the Traits framework when .edit_traits() is invoked.

updated = Event

Fired when the axis’s range bounds change.