chaco.plots.polygon_plot module

Defines the PolygonPlot class.

class chaco.plots.polygon_plot.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(requires_redraw=True)

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

edge_style = LineStyle(requires_redraw=True)

The line dash style for the edge of the polygon.

edge_width = Float(1.0, requires_redraw=True)

The thickness of the edge of the polygon.

effective_edge_color = Property(Tuple, observe=["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, observe=["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(requires_redraw=True)

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