ContourGenerator#

class contourpy.ContourGenerator#

Abstract base class for contour generator classes, defining the interface that they all implement.

class property default_fill_type#

Return the default FillType used by this algorithm.

class property default_line_type#

Return the default LineType used by this algorithm.

property chunk_count#

Return tuple of (y, x) chunk counts.

property chunk_size#

Return tuple of (y, x) chunk sizes.

property corner_mask#

Return whether corner_mask is set or not.

property fill_type#

Return the FillType.

filled(self: object, lower_level: float, upper_level: float) tuple#

Calculate and return filled contours between two levels.

Parameters:
  • lower_level (float) – Lower z-level of the filled contours.

  • upper_level (float) – Upper z-level of the filled contours.

Returns:

Filled contour polygons as one or more sequences of numpy arrays. The exact format is determined by the fill_type used by the ContourGenerator.

Raises a ValueError if lower_level >= upper_level.

To return filled contours below a level use filled(-np.inf, level). To return filled contours above a level use filled(level, np.inf)

property line_type#

Return the LineType.

lines(self: object, level: float) tuple#

Calculate and return contour lines at a particular level.

Parameters:

level (float) – z-level to calculate contours at.

Returns:

Contour lines (open line strips and closed line loops) as one or more sequences of numpy arrays. The exact format is determined by the line_type used by the ContourGenerator.

property quad_as_tri#

Return whether quad_as_tri is set or not.

static supports_corner_mask() bool#

Return whether this algorithm supports corner_mask.

static supports_fill_type(fill_type: contourpy._contourpy.FillType) bool#

Return whether this algorithm supports a particular FillType.

static supports_line_type(line_type: contourpy._contourpy.LineType) bool#

Return whether this algorithm supports a particular LineType.

static supports_quad_as_tri() bool#

Return whether this algorithm supports quad_as_tri.

static supports_threads() bool#

Return whether this algorithm supports the use of threads.

static supports_z_interp() bool#

Return whether this algorithm supports z_interp values other than ZInterp.Linear which all support.

property thread_count#

Return the number of threads used.

property z_interp#

Return the ZInterp.

class contourpy.Mpl2005ContourGenerator#

Bases: ContourGenerator

ContourGenerator corresponding to name="mpl2005".

This is the original 2005 Matplotlib algorithm. Does not support any of corner_mask, quad_as_tri, threads or z_interp. Only supports line_type=LineType.SeparateCode and fill_type=FillType.OuterCode. Only supports chunking for filled contours, not contour lines.

Warning

This algorithm is in contourpy for historic comparison. No new features or bug fixes will be added to it, except for security-related bug fixes.

class contourpy.Mpl2014ContourGenerator#

Bases: ContourGenerator

ContourGenerator corresponding to name="mpl2014".

This is the 2014 Matplotlib algorithm, a replacement of the original 2005 algorithm that added corner_mask and made the code more maintainable. Only supports corner_mask, does not support quad_as_tri, threads or z_interp. Only supports line_type=LineType.SeparateCode and fill_type=FillType.OuterCode.

Warning

This algorithm is in contourpy for historic comparison. No new features or bug fixes will be added to it, except for security-related bug fixes.

class contourpy.SerialContourGenerator#

Bases: ContourGenerator

ContourGenerator corresponding to name="serial", the default algorithm for contourpy.

Supports corner_mask, quad_as_tri and z_interp but not threads. Supports all options for line_type and fill_type.

class contourpy.ThreadedContourGenerator#

Bases: ContourGenerator

ContourGenerator corresponding to name="threaded", the multithreaded version of SerialContourGenerator.

Supports corner_mask, quad_as_tri and z_interp and threads. Supports all options for line_type and fill_type.