chaco.plots.segment_plot module

class chaco.plots.segment_plot.ColormappedSegmentPlot(**kwtraits)

Bases: chaco.plots.segment_plot.SegmentPlot

class chaco.plots.segment_plot.SegmentPlot(**kwtraits)

Bases: chaco.base_xy_plot.BaseXYPlot

Plot that draws a collection of line segments.

color = black_color_trait(redraw=True)

The single color to use when color_by_data is False.

color_by_data = Bool(False)

Whether to draw segments using a constant color or colormapped data.

color_data = Instance(AbstractDataSource, redraw=True)

The data to use for the segment color. Used only when self.color_by_data is True.

color_mapper = Instance(AbstractColormap, redraw=True)

The color mapper to use for the segment data. Used only when self.color_by_data is True.

effective_colors = Property(

RGBA values for rendering individual segments, in the case where color_by_data is True. This is a length N array with the rgba_dtype and are computed using the current color or color mapper and color_data, with the global ‘alpha’ mixed in.

get_closest_line(*args, **kwargs)

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(*args, **kwargs)

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

hittest(*args, **kwargs)

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.

line_style = LineStyle(redraw=True)

The line dash style.

line_width = Float(1.0, redraw=True)

The thickness of the line.

map_index(*args, **kwargs)

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 Nx2x2 array of data points into screen space and returns it as an array. Implements the AbstractPlotRenderer interface.

render_orientation = Enum("index", "value")

When rendering certain styles, which orientation to prefer.

render_style = Enum("line", "orthogonal", "quad", "cubic")

The rendering style of the segment plot.

line

“Normal” direct connection between start and end points.

orthogonal

Connect the start and end points by two line segments in orthogonal directions.

quad

Connect the start and end points by a quadratic Bezier curve.

cubic

Connect the start and end points by a cubic Bezier curve.

For non-linear segments, the tangent at the start matches the orientation of the plot (ie. horizontal orientation means a horizontal tangent).

screen_widths = Property(

The widths of the individual lines in screen units, if mapped to data. The values are computed with the width mapper.

selection_alpha = Float(0.3)

The alpha fade to use for non-selected segments.

selection_color = ColorTrait("yellow")

The color to use for selected segments. Not used if color by data.

selection_metadata_name = Str("selections")

the plot data metadata name to watch for selection information

selection_width = Float(1.0)

The width multiple to use for non-selected segments.

show_selection = True

Whether or not to shade selected segments.

width_by_data = Bool(False, redraw=True)

Whether to draw segments using a constant width or mapped width.

width_data = Instance(AbstractDataSource, redraw=True)

The data to use for segment width. Used only when self.width_by_data is True.

width_mapper = Instance(AbstractMapper, redraw=True)

Whether to draw segments using a constant width or mapped width.