Renderers

BarPlot

class chaco.api.BarPlot(*args, **kw)

Bases: chaco.abstract_plot_renderer.AbstractPlotRenderer

A renderer for bar charts.

alpha = Range(0.0, 1.0, 1.0)

Overall alpha value of the image. Ranges from 0.0 for transparent to 1.0

antialias = Bool(True)

Round on rectangle dimensions? This is not strictly an “antialias”, but it has the same effect through exact pixel drawing.

bar_width = Float(10)

Width of the bars, in data or screen space (determined by bar_width_type).

bar_width_type = Enum("data", "screen")

Type of width used for bars:

‘data’

The width is in the units along the x-dimension of the data space.

‘screen’

The width uses a fixed width of pixels.

effective_fill_color = Property(Tuple, depends_on=['fill_color', 'alpha'])

The RGBA tuple for rendering the fill. It is always a tuple of length 4. It has the same RGB values as fill_color_, and its alpha value is the alpha value of self.fill_color multiplied by self.alpha.

effective_line_color = Property(Tuple, depends_on=['line_color', 'alpha'])

The RGBA tuple for rendering lines. It is always a tuple of length 4. It has the same RGB values as line_color_, and its alpha value is the alpha value of self.line_color multiplied by self.alpha.

fill_color = black_color_trait

Color to fill the bars.

index = Instance(ArrayDataSource)

The data source to use for the index coordinate.

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

The direction of the index axis with respect to the graphics context’s direction.

index_mapper = Instance(AbstractMapper)

Labels for the indices.

index_range = Property

Convenience property for accessing the index data range.

line_color = black_color_trait

Color of the border of the bars.

line_width = Float(1.0)

Width of the border of the bars.

map_data(screen_pt)

Maps a screen space point into the “index” space of the plot.

Implements the AbstractPlotRenderer interface.

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

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

Implements the AbstractPlotRenderer interface.

map_screen(data_array)

Maps an array of data points into screen space and returns it as an array.

Implements the AbstractPlotRenderer interface.

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

The orientation of the index axis.

starting_value = Instance(ArrayDataSource)

The data source to use as “starting” values for bars (along value axis). For instance, if the values are [10, 20] and starting_value is [3, 7], BarPlot will plot two bars, one between 3 and 10, and one between 7 and 20

value = Instance(ArrayDataSource)

The data source to use as value points.

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

The direction of the value axis with respect to the graphics context’s direction.

value_mapper = Instance(AbstractMapper)

Labels for the values.

value_range = Property

Convenience property for accessing the value data range.

x_direction = Property

Corresponds to either index_direction or value_direction, depending on the orientation of the plot.

x_mapper = Property

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

y_direction = Property

Corresponds to either value_direction or index_direction, depending on the orientation of the plot

y_mapper = Property

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

Base1DPlot

class chaco.api.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(depends_on=['orientation', 'index_mapper'])

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

y_mapper = Property(depends_on=['orientation', 'index_mapper'])

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

Base2DPlot

class chaco.api.Base2DPlot(**kwargs)

Bases: chaco.abstract_plot_renderer.AbstractPlotRenderer

Base class for 2-D plots.

alpha = Trait(1.0, Range(0.0, 1.0))

Overall alpha value of the image. Ranges from 0.0 for transparent to 1.0 for full intensity.

draw_layer = "image"

Overrides PlotComponent; 2-D plots draw on the ‘image’ layer, underneath all decorations and annotations, and above only the background fill color.

index = Instance(GridDataSource)

The data source to use for the index coordinate.

index_data_changed = Event

Event fired when the index data changes. Subclasses can listen for this event and take appropriate steps (except for requesting a redraw, which is done in this class).

index_mapper = Instance(GridMapper)

Screen mapper for 2-D structured (gridded) index data.

index_mapper_changed = Event

Event fired when the index mapper changes. Subclasses can listen for this event and take appropriate steps (except for requesting a redraw, which is done in this class).

index_range = Property

Convenience property for accessing the data range of the mapper.

labels = Property

Convenience property for accessing the plots labels.

map_data(screen_pts)

Maps a screen space point into the “index” space of the plot.

Implements the AbstractPlotRenderer interface.

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

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

Implements the AbstractPlotRenderer interface. The index_only parameter is ignored because the index is intrinsically 2-D.

map_screen(data_pts)

Maps an array of data points into screen space and returns it as an array.

Implements the AbstractPlotRenderer interface.

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

The direction that the first array returned by self.index.get_data() maps to.

  • ‘h’: index maps to x-direction

  • ‘v’: index maps to y-direction

value = Instance(ImageData)

The data source to use as value points.

value_data_changed = Event

Event fired when the value data changes. Subclasses can listen for this event and take appropriate steps (except for requesting a redraw, which is done in this class).

x_mapper = Property

Convenience property for accessing the x-direction mappers regardless of orientation. This provides compatibility with a number of tools.

y_mapper = Property

Convenience property for accessing the y-direction mappers regardless of orientation. This provides compatibility with a number of tools.

BaseXYPlot

class chaco.api.BaseXYPlot(**kwtraits)

Bases: chaco.abstract_plot_renderer.AbstractPlotRenderer

Base class for simple X-vs-Y plots that consist of a single index data array and a single value data array.

Subclasses handle the actual rendering, but this base class takes care of most of making sure events are wired up between mappers and data or screen space changes, etc.

alpha = Range(0.0, 1.0, 1.0)

Overall alpha value of the image. Ranges from 0.0 for transparent to 1.0

bgcolor = "transparent"

Overrides the default background color trait in PlotComponent.

get_closest_line(screen_pt, threshold=7.0)

Tests for proximity in screen-space against lines connecting the points in this plot’s dataset.

Parameters
  • screen_pt ((x,y)) – A point to test.

  • threshold (integer) – Optional maximum screen space distance (pixels) between the line and the plot. If 0.0, then the method returns the closest line regardless of distance from the plot.

Returns

  • (x1, y1, x2, y2, dist) of the endpoints of the line segment

  • closest to *screen_pt. The dist element is the perpendicular*

  • distance from *screen_pt to the line. If there is only a single point*

  • in the renderer’s data, then the method returns the same point twice.

  • If no data points are within *threshold of screen_pt, returns None.*

get_closest_point(screen_pt, threshold=7.0)

Tests for proximity in screen-space.

This method checks only data points, not the line segments connecting them; to do the latter use get_closest_line() instead.

Parameters
  • screen_pt ((x,y)) – A point to test.

  • threshold (integer) – Optional maximum screen space distance (pixels) between screen_pt and the plot. If 0.0, then no threshold tests are performed, and the nearest point is returned.

Returns

  • (x, y, distance) of a datapoint nearest to *screen_pt.*

  • If no data points are within *threshold of screen_pt, returns None.*

get_screen_points()

Returns the currently visible screen-space points.

Intended for use with overlays.

hgrid = Property

Read-only property for horizontal grid.

hittest(screen_pt, threshold=7.0, return_distance=False)

Performs proximity testing between a given screen point and the plot.

Parameters
  • screen_pt ((x,y)) – A point to test.

  • threshold (integer) – Optional maximum screen space distance (pixels) between screen_pt and the plot.

  • return_distance (Boolean) – If True, also return the distance.

Returns

  • If self.hittest_type is ‘point’, then this method returns the screen

  • coordinates of the closest point on the plot as a tuple (x,y)

  • If self.hittest_type is ‘line’, then this method returns the screen

  • endpoints of the line segment closest to *screen_pt, as*

  • ((x1,y1), (x2,y2))

  • If *screen_pt does not fall within threshold of the plot, then this*

  • method returns None.

  • If return_distance is True, return the (x, y, d), where d is the

  • distance between the distance between the input point and

  • the closest point (x, y), in screen coordinates.

hittest_type = Enum("point", "line")

The type of hit-testing that is appropriate for this renderer.

  • ‘line’: Computes Euclidean distance to the line between the nearest adjacent points.

  • ‘point’: Checks for adjacency to a marker or point.

index = Instance(ArrayDataSource)

The data source to use for the index coordinate.

index_mapper = Instance(AbstractMapper)

Screen mapper for index data.

index_range = Property

Convenience property for accessing the index data range.

labels = Property

Read-only property for labels.

map_data(screen_pt, all_values=False)

Maps a screen space point into the “index” space of the plot.

Implements the AbstractPlotRenderer interface.

If all_values is True, returns an array of (index, value) tuples; otherwise, it returns only the index values.

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

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

Implements the AbstractPlotRenderer interface.

Parameters
  • screen_pt – Screen space point

  • threshold (float) – Maximum distance from screen space point to plot data point. A value of 0.0 means no threshold (any distance will do).

  • outside_returns_none (bool) – If True, a screen space point outside the data range returns None. Otherwise, it returns either 0 (outside the lower range) or the last index (outside the upper range)

  • index_only (bool) – If True, the threshold is measured on the distance between the index values, otherwise as Euclidean distance between the (x,y) coordinates.

map_screen(data_array)

Maps an array of data points into screen space and returns it as an array.

Implements the AbstractPlotRenderer interface.

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

The orientation of the index axis.

origin_axis_color = black_color_trait

Defines the origin axis color, for testing.

origin_axis_visible = Bool(False)

Defines the origin axis visibility, for testing.

origin_axis_width = Float(1.0)

Defines a the origin axis width, for testing.

use_downsampling = Bool(False)

Does the plot use downsampling? This is not used right now. It needs an implementation of robust, fast downsampling, which does not exist yet.

use_subdivision = Bool(False)

Does the plot use a spatial subdivision structure for fast hit-testing? This makes data updates slower, but makes hit-tests extremely fast.

value = Instance(AbstractDataSource)

The data source to use as value points.

value_mapper = Instance(AbstractMapper)

Screen mapper for value data

value_range = Property

Convenience property for accessing the value data range.

vgrid = Property

Read-only property for vertical grid.

x_axis = Property

Read-only property for x-axis.

x_mapper = Property

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

y_axis = Property

Read-only property for y-axis.

y_mapper = Property

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

ScatterPlot

class chaco.api.ScatterPlot(**kwtraits)

Bases: chaco.base_xy_plot.BaseXYPlot

Renders a scatter plot, given an index and value arrays.

map_data(screen_pt, all_values=True)

Maps a screen space point into the “index” space of the plot.

Overrides the BaseXYPlot implementation, and always returns an array of (index, value) tuples.

map_index(screen_pt, threshold=0.0, outside_returns_none=True, index_only=False)

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

Overrides the BaseXYPlot implementation..

map_screen(data_array)

Maps an array of data points into screen space and returns it as an array.

Implements the AbstractPlotRenderer interface.

ImagePlot

class chaco.api.ImagePlot(**kwargs)

Bases: chaco.base_2d_plot.Base2DPlot

A plot based on an image.

alpha = Trait(1.0, Range(0.0, 1.0))

Overall alpha value of the image. Ranges from 0.0 for transparent to 1.0 for full intensity.

interpolation = Enum("nearest", "bilinear", "bicubic")

The interpolation method to use when rendering an image onto the GC.

map_index(screen_pt, threshold=0.0, outside_returns_none=True, index_only=False)

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

Implements the AbstractPlotRenderer interface. Uses 0.0 for threshold, regardless of the passed value.

x_axis_is_flipped = Property(depends_on=['orientation', 'origin'])

Bool indicating whether x-axis is flipped.

y_axis_is_flipped = Property(depends_on=['orientation', 'origin'])

Bool indicating whether y-axis is flipped.

CMapImagePlot

class chaco.api.CMapImagePlot(**kwargs)

Bases: chaco.image_plot.ImagePlot

Colormapped image plot. Takes a value data object whose elements are scalars, and renders them as a colormapped image.

cache_full_map = Bool(True)

whether to pre-compute the full colormapped RGB(A) image

color_mapper = Property

Convenience property for value_mapper as color_mapper

fade_alpha = Float(0.3)

alpha value to use to fade out unselected data points when there is an active selection

fade_background = Tuple((0,0,0))

RGB color to use to fade out unselected points.

set_value_selection(val)

Sets a range of values in the value data source as selected.

value_mapper = Instance(AbstractColormap)

Maps from scalar data values in self.data.value to color tuples

value_range = Property

Convenience property for accessing the data range of the mapper.

ContourLinePlot

class chaco.api.ContourLinePlot(*args, **kwargs)

Bases: chaco.base_contour_plot.BaseContourPlot

Takes a value data object whose elements are scalars, and renders them as a contour plot.

negative_style = LineStyle("dash")

Line style for negative levels.

positive_style = LineStyle("solid")

Line style for positive levels.

styles = Trait("signed", Str, List)

The line dash style(s).

widths = Trait(1.0, Float, List)

The thickness(es) of the contour lines. It can be either a scalar value, valid for all contour lines, or a list of widths. If the list is too short with respect to then number of contour lines, the values are repeated from the beginning of the list. Widths are associated with levels of increasing value.

LinePlot

class chaco.api.LinePlot(**kwtraits)

Bases: chaco.base_xy_plot.BaseXYPlot

A plot consisting of a line.

This is the most fundamental object to use to create line plots. However, it is somewhat low-level and therefore creating one properly to do what you want can require some verbose code. The create_line_plot() function in plot_factory.py can hide some of this verbosity for common cases.

color = black_color_trait

The color of the line.

effective_color = Property(Tuple, depends_on=['color', 'alpha'])

The RGBA tuple for rendering lines. It is always a tuple of length 4. It has the same RGB values as color_, and its alpha value is the alpha value of self.color multiplied by self.alpha.

get_screen_points()

Returns the currently visible screen-space points.

Intended for use with overlays.

hittest(screen_pt, threshold=7.0, return_distance=False)

Tests whether the given screen point is within threshold pixels of any data points on the line. If so, then it returns the (x,y) value of a data point near the screen point. If not, then it returns None.

interpolate(index_value)

Returns the value of the plot at the given index value in screen space. Raises an IndexError when index_value exceeds the bounds of indexes on the value.

line_style = LineStyle

The line dash style.

line_width = Float(1.0)

The thickness of the line.

metadata_name = Str("selections")

The name of the key in self.metadata that holds the selection mask

render_style = Enum("connectedpoints", "hold", "connectedhold")

The rendering style of the line plot.

connectedpoints

“normal” style (default); each point is connected to subsequent and prior points by line segments

hold

each point is represented by a line segment parallel to the abscissa (index axis) and spanning the length between the point and its subsequent point.

connectedhold

like “hold” style, but line segments are drawn at each point of the plot to connect the hold lines of the prior point and the current point. Also called a “right angle plot”.

selected_color = ColorTrait("lightyellow")

The color to use to highlight the line when selected.

selected_line_style = LineStyle("solid")

The style of the selected line.

traits_view

Traits UI View for customizing the plot.

ColormappedScatterPlot

class chaco.api.ColormappedScatterPlot(**kwtraits)

Bases: chaco.scatterplot.ScatterPlot

A scatter plot that allows each point to take on a different color, corresponding to a color map.

If the color_data or color_mapper attributes are None, then it behaves like a normal ScatterPlot.

color_data = Instance(ArrayDataSource)

Source for color data.

color_mapper = Instance(AbstractColormap)

Mapping for colors.

fill_alpha = Float(1.0)

The alpha value to apply to the result of the color-mapping process. (This makes it easier to create color maps without having to worry about alpha.)

map_screen(data_array)

Maps an array of data points into screen space, and returns them as an array.

The data_array parameter must be an Nx2 (index, value) or Nx3 (index, value, color_value) array. The returned array is an Nx2 array of (x, y) tuples.

render_method = Enum("auto", "banded", "bruteforce")

Determines what drawing approach to use:

banded:

Draw the points color-band by color-band, thus reducing the number of set_stroke_color() calls. Disadvantage is that some colors will appear more prominently than others if there are a lot of overlapping points.

bruteforce:

Set the stroke color before drawing each marker. Slower, but doesn’t produce the banding effect that puts some colors on top of others; useful if there is a lot of overlap of the data.

auto:

Determines which render method to use based on the number of points

TODO: Based on preliminary results, “banded” isn’t significantly more expensive than “bruteforce” for small datasets (<1000), so perhaps banded should be removed.

traits_view

Traits UI View for customizing the plot. Overrides the ScatterPlot value.

ColormappedSelectionOverlay

class chaco.api.ColormappedSelectionOverlay(component=None, **kw)

Bases: chaco.abstract_overlay.AbstractOverlay

Overlays and changes a ColormappedScatterPlot to fade its non-selected points to a very low alpha.

fade_alpha = Float(0.15)

The amount to fade the unselected points.

minimum_delta = Float(0.01)

The minimum difference, in float percent, between the starting and ending selection values, if range selection mode is enabled

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

Draws this component overlaid on another component.

Implements AbstractOverlay.

plot = Property

The ColormappedScatterPlot that this overlay is listening to. By default, it looks at self.component

selected_outline_width = Float(1.0)

Outline width for selected points.

selection_type = Enum('range', 'mask')

The type of selection used by the data source.

unselected_outline_width = Float(0.0)

Outline width for unselected points.

PolygonPlot

class chaco.api.PolygonPlot(**kwtraits)

Bases: chaco.base_xy_plot.BaseXYPlot

Plots a polygon in dataspace.

Assuming that the index and value mappers are linear mappers, and that “index” corresponds to X-coordinates and “value” corresponds to Y-coordinates, the points are arranged in a counter-clockwise fashion. The polygon is closed automatically, so there is no need to reproduce the first point as the last point.

Nonlinear mappers are possible, but the results may be unexpected. Only the data-space points are mapped in a nonlinear fashion. Straight lines connecting them in a linear screen-space become curved in a nonlinear screen-space; however, the drawing still contains straight lines in screen-space.

If you don’t want the edge of the polygon to be drawn, set edge_color to transparent; don’t try to do this by setting edge_width to 0. In some drawing systems, such as PostScript, a line width of 0 means to make the line as small as possible while still putting ink on the page.

edge_color = black_color_trait

The color of the line on the edge of the polygon.

edge_style = LineStyle

The line dash style for the edge of the polygon.

edge_width = Float(1.0)

The thickness of the edge of the polygon.

effective_edge_color = Property(Tuple, depends_on=['edge_color', 'alpha'])

The RGBA tuple for rendering edges. It is always a tuple of length 4. It has the same RGB values as edge_color_, and its alpha value is the alpha value of self.edge_color multiplied by self.alpha.

effective_face_color = Property(Tuple, depends_on=['face_color', 'alpha'])

The RGBA tuple for rendering the face. It is always a tuple of length 4. It has the same RGB values as face_color_, and its alpha value is the alpha value of self.face_color multiplied by self.alpha.

face_color = transparent_color_trait

The color of the face of the polygon.

hittest(screen_pt, threshold=7.0, return_distance=False)

Performs point-in-polygon testing or point/line proximity testing. If self.hittest_type is “line” or “point”, then behaves like the parent class BaseXYPlot.hittest().

If self.hittest_type is “poly”, then returns True if the given point is inside the polygon, and False otherwise.

hittest_type = Enum("poly", "point", "line")

Override the hittest_type trait inherited from BaseXYPlot

ErrorBarPlot

class chaco.api.ErrorBarPlot(**kwtraits)

Bases: chaco.lineplot.LinePlot

Renders errorbars at various points.

endcap_size = Float(5.0)

The screen-space width of the endcap bars

endcap_style = Enum("bar", "none", None)

The kind of encap to render on error bars

get_screen_points()

Returns the currently visible screen-space points.

Intended for use with overlays.

map_screen(data_array)

data_array can be Nx2 or Nx3. In the former case, each row is treated as (index, value), and this method returns screen X and Y coordinates. In the latter case, each row is treated as (index, value_low, value_high), and the method returns either (x, ylow, yhigh) or (y, xlow, xhigh) depending on self.orientation.

value_high = Instance(AbstractDataSource)

The datasource containing the high values

value_low = Instance(AbstractDataSource)

The datasource containing the low values

FilledLinePlot

class chaco.api.FilledLinePlot(**kwtraits)

Bases: chaco.polygon_plot.PolygonPlot

Draws a line plot filled to the axis

fill_direction = Enum("down", "up")

Direction to fill. Down is towards the origin, up is towards the max

render_style = Enum("connectedpoints", "hold", "connectedhold")

The rendering style of the line plot.

connectedpoints

“normal” style (default); each point is connected to subsequent and prior points by line segments

hold

each point is represented by a line segment parallel to the abscissa (index axis) and spanning the length between the point and its subsequent point.

connectedhold

like “hold” style, but line segments are drawn at each point of the plot to connect the hold lines of the prior point and the current point. Also called a “right angle plot”.

QuiverPlot

class chaco.api.QuiverPlot(**kwtraits)

Bases: chaco.scatterplot.ScatterPlot

arrow_size = Int(5)

The length, in pixels, of the arrowhead

data_type = Enum("vector", "radial") # TODO: implement "radial"

Determines how to interpret the data in the vectors data source. “vector”: each tuple is a (dx, dy) “radial”: each tuple is an (r, theta)

line_color = ColorTrait("black")

The color of the lines

line_width = Float(1.0)

The width of the lines

vectors = Instance(AbstractDataSource)

A datasource that returns an Nx2 array array indicating directions of the vectors. The interpretation of this array is dependent on the setting of the data_type attribute.

Usually this will be a MultiArrayDataSource.

CandlePlot

class chaco.api.CandlePlot(**kwtraits)

Bases: chaco.base_candle_plot.BaseCandlePlot

A plot consisting of a filled bar with an optional centerline and stems extending to extrema. Usually used to represent some statistics on bins of data, with the centerline representing the mean, the bar extents representing +/- 1 standard dev or 10th/90th percentiles, and the stems extents representing the minimum and maximum samples.

The values in the index datasource indicate the centers of the bins; the widths of the bins are not specified in data space, and are determined by the minimum space between adjacent index values.

bar_max = Instance(AbstractDataSource)

The “upper” extent of the “bar”, i.e. the value closest to the corresponding value in max_values at each index.

bar_min = Instance(AbstractDataSource)

The “lower” extent of the “bar”, i.e. the value closest to the corresponding value in min_values at each index.

center_values = Instance(AbstractDataSource)

Values that appear inside the bar, between bar_min and bar_max. These Are usually mean or median values, and are rendered with a solid line of a different color than the bar fill color. This can be None.

map_data(screen_pt, all_values=True)

Maps a screen space point into the “index” space of the plot.

Overrides the BaseXYPlot implementation, and always returns an array of (index, value) tuples.

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

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

Implements the AbstractPlotRenderer interface.

Parameters
  • screen_pt – Screen space point

  • threshold (float) – Maximum distance from screen space point to plot data point. A value of 0.0 means no threshold (any distance will do).

  • outside_returns_none (bool) – If True, a screen space point outside the data range returns None. Otherwise, it returns either 0 (outside the lower range) or the last index (outside the upper range)

  • index_only (bool) – If True, the threshold is measured on the distance between the index values, otherwise as Euclidean distance between the (x,y) coordinates.

max_values = Instance(AbstractDataSource)

The maximum value at each index point. If None, then no stem and no endcap line will be drawn above each bar.

min_values = Instance(AbstractDataSource)

The minimum values at each index point. If None, then no stem and no endcap line will be drawn below each bar.

MultiLinePlot

class chaco.api.MultiLinePlot(**kwtraits)

Bases: chaco.base_xy_plot.BaseXYPlot

A plot consisting of multiple lines.

The data to be plotted must come from a two-dimensional array with shape M by N stored in a MultiArrayDataSource object. M is the number of lines to be plotted, and N is the number of points in each line.

Parameters
  • index (instance of an ArrayDataSource) – These are the ‘x’ or abscissa coordinates.

  • yindex (instance of ArrayDataSource) – These are the ‘y’ coordinates.

  • value (instance of a MultiArrayDataSource) – Note that the scale, offset and normalized_amplitude attributes of the MultiLinePlot control the projection of the traces into the (x,y) plot. In simplest case, scale=1 and offset=0, and normalized_amplitude controls the scaling of the traces relative to their base y value.

  • global_min (float) – The minimum and maximum values of the data in value. For large arrays, computing these could take excessive time, so they must be provided when an instance is created.

  • global_max (float) – The minimum and maximum values of the data in value. For large arrays, computing these could take excessive time, so they must be provided when an instance is created.

  • normalized_amplitude (Float) –

  • color (ColorTrait) –

  • color_func (Callable or None) – If not None, this Callable overrides color. The argument to color_func will be the integer index of the trace to be rendered. color_func must return an RGBA 4-tuple. Default: None

  • orientation (str) – Must be ‘v’ or ‘h’ (for ‘vertical’ or ‘horizontal’, respectively). This is the orientation of the index axis (i.e. the ‘x’ axis). Default: ‘h’

  • fast_clip (bool) – If True, traces whose base ‘y’ coordinate is outside the value axis range are not plotted, even if some of the data in the curve extends into the plot region. Default: False

  • line_width (float) – Width of the plotted lines.

  • line_style – The style of the trace lines in the plot.

  • following are from the original LinePlot code (The) –

  • are untested (and) –

  • selected_color

  • selected_line_style

color = black_color_trait

The color of the lines.

color_func = Trait(None, None, Callable)

A function that returns the color of lines. Overrides color if not None.

get_screen_points()

Returns the currently visible screen-space points.

Intended for use with overlays.

global_max = Float

Maximum value in the value data source. This must be provided in the call to the constructor.

global_min = Float

Minimum value in the value data source. This must be provided in the call to the constructor.

line_style = LineStyle

The line dash style.

line_width = Float(1.0)

The thickness of the line.

metadata_name = Str("selections")

The name of the key in self.metadata that holds the selection mask

normalized_amplitude = Float(-0.5)

Normalized amplitude is the value exposed to the user.

scale = Float(1.0)

scale and offset provide a more general transformation, but are currently untested.

selected_color = ColorTrait("lightyellow")

The color to use to highlight the line when selected.

selected_line_style = LineStyle("solid")

The style of the selected line.

trait_view(obj)

Create a minimalist View, with just the amplitude and color attributes.

ScatterPlot1D

class chaco.api.ScatterPlot(**kwtraits)

Bases: chaco.base_xy_plot.BaseXYPlot

Renders a scatter plot, given an index and value arrays.

map_data(screen_pt, all_values=True)

Maps a screen space point into the “index” space of the plot.

Overrides the BaseXYPlot implementation, and always returns an array of (index, value) tuples.

map_index(screen_pt, threshold=0.0, outside_returns_none=True, index_only=False)

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

Overrides the BaseXYPlot implementation..

map_screen(data_array)

Maps an array of data points into screen space and returns it as an array.

Implements the AbstractPlotRenderer interface.

..:class:JitterPlot ..=================== …. autoclass:: JitterPlot .. :members: .. :show-inheritance:

..:class:LineScatterPlot1D ..=================== …. autoclass:: LineScatterPlot1D .. :members: .. :show-inheritance:

..:class:TextPlot1D ..=================== …. autoclass:: TextPlot1D .. :members: .. :show-inheritance:

VariableSizeScatterPlot

class chaco.api.VariableSizeScatterPlot(**kwtraits)

Bases: chaco.scatterplot.ScatterPlot

HorizonPlot

class chaco.api.HorizonPlot(**kwtraits)

Bases: chaco.base_xy_plot.BaseXYPlot

negative_bands = Bool(True)

FIXME There should be a way to automatically detect whether the data has negative bands